亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

基于滾動條位置判斷的簡單實(shí)例

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

實(shí)例如下所示:

//獲取滾動條距離頂部位置
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;
}
//獲取當(dāng)前可視范圍的高度
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);
}
//判斷滾動條是否達(dá)到底部
getScrollTop() + getClientHeight() == getScrollHeight()

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

相關(guān)文章

最新評論