欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于滾動條位置判斷的簡單實例

 更新時間:2017年12月14日 15:20:12   作者:止戰(zhàn)之殤丶  
下面小編就為大家分享一篇基于滾動條位置判斷的簡單實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

實例如下所示:

//獲取滾動條距離頂部位置
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);
}
//判斷滾動條是否達到底部
getScrollTop() + getClientHeight() == getScrollHeight()

以上這篇基于滾動條位置判斷的簡單實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論