Created
August 28, 2014 08:45
-
-
Save wangwen1220/2e9825b8557550e38e17 to your computer and use it in GitHub Desktop.
js:判断滚动条已经滚动到底部
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
// 判断滚动条已经滚动到底部 | |
if (Math.abs(document.body.clientHeight - document.documentElement.clientHeight) <= (document.documentElement.scrollTop || document.body.scrollTop)) { | |
alert("滚到底部"); | |
} |
if(scroll_elem.scrollHeight>scroll_elem.clientHeight){
scroll_elem.addEventListener('scroll',function(){
//...
})
}else {
window.addEventListener('scroll',function(){
//...
})
}
我现在遇到的问题是
电脑端
模式可以检测到滚动到底部,进入手机端
模式后scrollHight
没有标准地改变导致不能满足条件
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
前提是 body 的滚动,如果是 某一个 dom 节点内的 滚动场景则不适用,建议完善。