js里獲取頁面高度和文檔高度


$(window).height() 和 $(document).height()的區別

$(window).height()代表了當前可見區域的大小,
$(document).height()則代表了整個文檔的高度,可視具體情況使用.

當瀏覽器窗口大小改變時(如最大化或拉大窗口后) ,
$(window).height() 隨之改變,但是 $(document).height()是不變的。

 

原生js里獲取頁面高度和文檔高度

document.body.clientHeight相當於$(window).height()

document.body.scrollHeight相當於$(document).height()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM