
팁과노하우
아래로 당겨서 새로고침하기
웹뷰사용시 새로고침버튼이 없어서 새로고침하려면 불편하더라고요
네이버카페어플이나 기타 어플 같은경우 아래로 스크롤 하면 새로고침이 되는데
그방법입니다 저는 할줄 몰라서 돈주고 배웠습니다 고수님들은 금방하시겠지만
저처럼 초보자들에게 필요할까 해서 공유합니다
적용하고싶은 페이지에 아래내용 넣어주시면 됩니다
<style>
body {
font-family: 'Nanum Myeongjo', 'Apple SD Gothic Neo', '���� ����', serif;
line-height: 1.6;
background-color: #f8f9fa;
color: #333;
overscroll-behavior: contain;
ㅂ}
</style>
<script src="https://unpkg.com/pulltorefreshjs" defer></script>
<script>
document.addEventListener("DOMContentLoaded", () => {
PullToRefresh.init({
mainElement: '#scroll_container', // 새로고침이 작동할 스크롤 컨테이너
onRefresh() {
return new Promise((resolve, reject) => {
$.ajax({
url: window.location.href,
dataType: 'html',
success: function(data) {
// 임시 DOM 객체에 전체 HTML 삽입 후, #scroll_container의 내용 추출
var newContent = $('<div></div>').html(data).find('#scroll_container').html();
$('#scroll_container').html(newContent);
resolve();
},
error: function() {
resolve();
}
});
});
},
instructionsPullToRefresh: '당겨서 새로고침',
instructionsReleaseToRefresh: '놓으면 새로고침',
instructionsRefreshing: '새로고침 중...'
});
const counters = document.querySelectorAll(".stats-value");
counters.forEach(counter => {
const updateCount = () => {
const target = +counter.getAttribute("data-count");
const count = +counter.innerText.replace(/,/g, '');
const increment = target / 200; // 속도 조정
if (count < target) {
counter.innerText = Math.ceil(count + increment).toLocaleString();
setTimeout(updateCount, 10);
} else {
const suffix = counter.getAttribute("data-suffix") || "";
counter.innerText = target.toLocaleString() + suffix;
}
};
updateCount();
});
});
</script>
- 이전글게시판 뷰페이지 첨부사진보다 본문글이 위로 나오게하기2025.03.02
- 다음글네이버 카페처럼 메인화면에서 글쓰기버튼 추가2025.02.28
댓글목록


