javascript、jquery獲取網頁的高度和寬度

javascript:

可視區域寬document.documentElement.clientWidth  (width + padding)

可視區域高document.documentElement.clientHeight (height + padding)

可視區域寬document.body.offsetWidth (包括邊線的寬: width + padding + border)

可視區域高document.body.offsetHeight (包括邊線的高:height + padding + border)

內容高document.body.scrollHeight

文檔高document.body.offsetHeight

縱向滾動的距離 document.body.scrollTop || document.documentElement.scrollTop

橫向滾動的距離 document.body.scrollLeft || document.documentElement.scrollLeft

jquery:

可視區域寬  : $(window).width()  

可視區域高$(window).height()

頁面的文檔寬$(document).width();

頁面的文檔高$(document).height();

獲取滾動條到左邊的垂直寬度$(document).scrollLeft();

獲取滾動條到頂部的垂直高度$(document).scrollTop();javascript

相關文章
相關標籤/搜索