16個常見屬性
6個常見的瀏覽器表單屬性
document.documentElement.clientWidth 瀏覽器可視區域寬度
document.documentElement.clientHeight 瀏覽器可視區域高度
document.documentElement.scrollWidth 整個網頁的寬度
document.documentElement.scrollHeight 整個網頁的高度
document.body.scrollTop 網頁上方被卷(藏)起來的部分
document.body.scrollLeft 網頁左邊被卷(藏)起來的部分
6個常見的螢屏物件屬性
window.screen.width 設備寬度
window.screen.height 設備高度
window.screenTop 瀏覽器視窗離設備頂部的距離
window.screenLeft 瀏覽器視窗離設備左端的距離
window.screen.availHeight 設備實際作業區的高度
window.screen.availWidth 設備實際作業區的寬度
4個常用的dom屬性
div.offsetWidth div元素的寬
div.offsetHeight div元素的高
div.offsetLeft 元素相對網頁left的距離
div.offsetTop 元素相對網頁top的距離
詳情:
1.1 document.documentElement.clientWidth和document.documentElement.clientHeight指的是瀏覽器當前視窗視圖區域的實際寬高(不包括工具列及滾動條等)
由于IE8及JQ的$(window).height()在部分瀏覽器下會出錯, 所以建議如果要獲取瀏覽器可視區域高度,代碼如下
var win_h = window.innerHeight||document.documentElement.clientHeight;
1.2 document.documentElement.scrollWidth和document.documentElement.scrollHeight 是整個網頁的寬高, 包括可視區域和被卷起來的區域

1.3document.body.scrollTop 和 document.body.scrollLeft 是整個網頁的上方或者左邊被卷起來的部分(注意這里中間部分是body而不再是documentElement)

如果想要獲得下面的或者右面的, 那就用整個頁面的寬高document.documentElement.scrollHeight減去網頁上方被卷起來的部分document.body.scrollTop, 再減去當前瀏覽器視圖區域的高度document.documentElement.clientHeight即可.
2.1 window.screen.width 和 window.screen.height 是獲取你整個顯示幕螢屏大小的

2.2 window.screenTop 和 window.screenLeft 是瀏覽器視窗頂部/左端距離螢屏大小的:

2.3 window.screen.availHeight 和 window.screen.availWidth 是用戶螢屏實際作業區(減去任務欄等非作業區模塊大小)的高和寬:

宣告: 本文參考自https://www.cnblogs.com/vajoy/p/3705126.html, 僅用于學習, 請務做商用
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/177547.html
標籤:JavaScript
