移动端滑动加载
作者:
一沭丶 | 来源:发表于
2016-06-26 18:51 被阅读102次function scrollLoad(){
var scrollTop = 0;
var clientHeight = 0;
var scrollHeight = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
} else if (document.body) {
scrollTop = document.body.scrollTop;
}
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight: document.documentElement.clientHeight;
} else {
clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight: document.documentElement.clientHeight;
}
// 知识点:Math.max 比较大小,取最大值返回
scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
if (scrollTop + clientHeight +200 > scrollHeight) {
//滑到底部时 do something...
} else {
return false;
}
}
本文标题: 移动端滑动加载
本文链接:https://www.haomeiwen.com/subject/uifzdttx.html
网友评论