Skip to content

Instantly share code, notes, and snippets.

@callblueday
Last active December 20, 2015 19:18
Show Gist options
  • Save callblueday/6181913 to your computer and use it in GitHub Desktop.
Save callblueday/6181913 to your computer and use it in GitHub Desktop.
网页滚动条滚动加载函数
function (){
var times = 0;
//滚动条到网页头部的 高度,兼容ie,ff,chrome
var top = document.documentElement.scrollTop + document.body.scrollTop;
//网页的高度
var textheight = document.body.offsetHeight;
// 网页高度-top-当前窗口高度
if (textheight - top - window.innerHeight <= 50) {
if (times >= 20) {
return; //控制最大只能加载20次
}
times++;
doSomething();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment