JS簡單實(shí)現(xiàn)滑動加載數(shù)據(jù)的方法示例
本文實(shí)例講述了JS簡單實(shí)現(xiàn)滑動加載數(shù)據(jù)的方法。分享給大家供大家參考,具體如下:
//滑動 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); } //綁定事件 window.onscroll = function () { if (getScrollTop() + getClientHeight() == getScrollHeight()) { //dosomething } }
更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript切換特效與技巧總結(jié)》、《JavaScript查找算法技巧總結(jié)》、《JavaScript錯(cuò)誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)》
希望本文所述對大家JavaScript程序設(shè)計(jì)有所幫助。
- 基于JavaScript實(shí)現(xiàn)鼠標(biāo)向下滑動加載div的代碼
- js實(shí)現(xiàn)滑動到頁面底部自動加載更多功能
- js/jquery控制頁面動態(tài)加載數(shù)據(jù) 滑動滾動條自動加載事件的方法
- 當(dāng)滾動條滾動到頁面底部自動加載增加內(nèi)容的js代碼
- js實(shí)現(xiàn)滾動條滾動到頁面底部繼續(xù)加載
- JavaScript實(shí)現(xiàn)頁面滾動圖片加載(仿lazyload效果)
- 滑輪滾動到頁面底部ajax加載數(shù)據(jù)配合jsonp實(shí)現(xiàn)探討
- 使用jQuery或者原生js實(shí)現(xiàn)鼠標(biāo)滾動加載頁面新數(shù)據(jù)
- JS圖片根據(jù)鼠標(biāo)滾動延時(shí)加載的實(shí)例代碼
- 解析javascript瀑布流原理實(shí)現(xiàn)圖片滾動加載
相關(guān)文章
JavaScript圖像放大鏡效果實(shí)現(xiàn)方法詳解
這篇文章主要介紹了JavaScript圖像放大鏡效果實(shí)現(xiàn)方法詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06js利用與或運(yùn)算符優(yōu)先級實(shí)現(xiàn)if else條件判斷表達(dá)式
利用與或運(yùn)算符優(yōu)先級實(shí)現(xiàn)if else運(yùn)算,讓你的代碼更精簡。2010-04-04用Div仿showModalDialog模式菜單的效果的代碼
用Div仿showModalDialog模式菜單的效果的代碼...2007-03-03JS+CSS實(shí)現(xiàn)DIV層的展開、收縮效果
這篇文章主要介紹了JS+CSS實(shí)現(xiàn)DIV層的展開、收縮效果,以兩個(gè)完整實(shí)例介紹了JS控制DIV層的展開、收縮效果,感興趣的小伙伴們可以參考一下2016-01-01