var throldHold = 400; //兩次scroll事件觸發之間最小的事件間隔瀏覽器
window.onscroll = function(){spa
//主要是解決Firefox問題。Firefox你滑動的過程可能會出現加載屢次,code
//而其它瀏覽器只加載一次,因此延遲加載,致使在某段時間只執行一次事件
if (arguments.callee.timer) {
clearTimeout(arguments.callee.timer);
}
arguments.callee.timer = setTimeout(isDivScroll, throldHold);
}io
var isDivScroll = function(){
var marginBot = -1;
if (document.compatMode === "CSS1Compat"){
marginBot = document.documentElement.scrollHeight - (document.documentElement.scrollTop+document.body.scrollTop)- document.documentElement.clientHeight;
} else {
marginBot = document.body.scrollHeight - document.body.scrollTop - document.body.clientHeight;
}function
//這裏不要設置爲<=0,由於IE監控不到
if(marginBot <= 10) {class
//執行數據加載
scrollFunc();
}
}監控