1 、 滑动到底部再加载数据
$(function(){
$(window).scroll(function(){
var scrollH = document.documentElement.scrollHeight;
if (scrollH == (document.documentElement.scrollTop | document.body.scrollTop) + clientH){
//加载新数据
alert(“加载新数据”);
});
});
2 、 滑动一个屏幕再加载新的图片
$(function(){ $(window).scroll( function(){ var heightwindow = $(window).height(); var scrollTop = document.body.scrollTop || document.documentElement.scrollTop; var heightwindowsishewuru = Math.round(heightwindow/100) * 100; if((document.body.scrollTop % heightwindowsishewuru == 0 && document.body.scrollTop != 0 && document.documentElement.scrollTop == 0) || (document.body.scrollTop == 0 && document.documentElement.scrollTop % heightwindowsishewuru == 0 && document.documentElement.scrollTop != 0)){ //当往下滑一个屏幕的时 候再加载 alert("加载新的图片"); } }); });