前端开发关于滑动加载js判断方法

weex开发前端页面
前端开发导航栏切换页面
前端开发写页面

//滑动
function getScrollTop()
{
var scrollTop = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
}else if (document.body) {
scrollTop = document.body.scrollTop;
}
return scrollTop;
}

//获取当前可视范围的高度
function getClientHeight()
{
var clientHeight = 0;
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
}else {
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
}
return clientHeight;
}
//获取文档完整的高度
function getScrollHeight()
{
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
}
if (getScrollTop() + getClientHeight() == getScrollHeight()){
//do something ……
}

前端给页面后台怎么开发
前端页面项目开发
对外页面前端开发
赞(0)
前端开发者 » 前端开发关于滑动加载js判断方法
64K

评论 抢沙发

评论前必须登录!