jquery 모바일웹/웹 더보기 자동스크롤
제목 : jquery 모바일웹/웹 더보기 자동스크롤
소스 :
<script type="text/javascript">
<!--
//더보기 script(S)
var i = 2;
function receiveMessage(){
$.ajax({
url : "/m/common/exec_getMainGoodsList.asp",
data : "page=" + i + "&cate=<%=cate%>&listtype=<%=listtype%>",
error : function(html, status){
alert(html+'오류입니다.');
},
success : function(html, status){
i += 1;
if (html == 'no_data')
{
alert('더이상 상품이 존재하지않습니다.');
} else {
$(".cont_list").append(html);
}
}
});
}
/*
var scrollTimer, lastScrollFireTime = 0;
var myVar = setInterval(function() {
$(window).scroll(function(){
var minScrollTime = 99;
var now = new Date().getTime();
if (!scrollTimer) {
if (now - lastScrollFireTime > (1 * minScrollTime)) {
//if ($(window).scrollTop() + $('#footer').outerHeight() > $('.cont_list').outerHeight() ){
if ($(window).scrollTop() + $('#footer').height() + 300 > $(document).height() - $(window).height()){
receiveMessage();
clearInterval(myVar);
$("#result").append("t="+$(window).scrollTop()+", f="+$('#footer').height()+", w="+$(window).height()+"<br>");
}
lastScrollFireTime = now;
}
scrollTimer = setTimeout(function() {
scrollTimer = null;
lastScrollFireTime = new Date().getTime();
}, minScrollTime);
}
});
}, 100);
*/
$(window).scroll(function(){
var pp = $(window).scrollTop();
var hh = $(window).height();
var bd = $(document).height();
if(pp + hh >= bd){
receiveMessage();
//$("#result").append("t="+pp+", f="+hh+", w="+bd+"<br>");
}
});
//더보기 script(E)
//-->
</script>
내용 :
예제 소스 파일 :
출처 :