JS 各种网页尺寸判断实例方法_Javascript教程-查字典教程网
JS 各种网页尺寸判断实例方法
JS 各种网页尺寸判断实例方法
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:functionreachBottom(){varscrollTop=0;varclientHeight=0;varscr...

复制代码 代码如下:

function reachBottom() {

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;

}

scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);

if (scrollTop + clientHeight == scrollHeight) {

return true;

} else {

return false;

}

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类