這篇文章給大家分享的是有關web開發(fā)中如何實現(xiàn)基于滾動條位置判斷的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
錦江網(wǎng)站建設公司成都創(chuàng)新互聯(lián),錦江網(wǎng)站設計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為錦江上千家提供企業(yè)網(wǎng)站建設服務。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設要多少錢,請找那個售后服務好的錦江做網(wǎng)站的公司定做!
實例如下所示:
//獲取滾動條距離頂部位置 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()
感謝各位的閱讀!關于“web開發(fā)中如何實現(xiàn)基于滾動條位置判斷”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
網(wǎng)站標題:web開發(fā)中如何實現(xiàn)基于滾動條位置判斷
標題來源:http://jinyejixie.com/article44/ggcphe.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、企業(yè)網(wǎng)站制作、品牌網(wǎng)站設計、靜態(tài)網(wǎng)站、微信小程序、微信公眾號
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)