js浏览器滑动到底部加载数据

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();
     }
 }
监控

相关文章
相关标签/搜索