Last active
December 20, 2015 19:18
-
-
Save callblueday/6181913 to your computer and use it in GitHub Desktop.
网页滚动条滚动加载函数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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