當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
JS获取屏幕浏览器网页高度和宽度属性
生活随笔
收集整理的這篇文章主要介紹了
JS获取屏幕浏览器网页高度和宽度属性
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 網頁可見區域寬:document.body.clientWidth
2 網頁可見區域高:document.body.clientHeight
3 網頁可見區域寬:document.body.offsetWidth (包括邊線的寬)
4 網頁可見區域高:document.body.offsetHeight (包括邊線的寬)
5 網頁正文全文寬:document.body.scrollWidth
6 網頁正文全文高:document.body.scrollHeight
7 網頁被卷去的高:document.body.scrollTop
8 網頁被卷去的左:document.body.scrollLeft
9 網頁正文部分上:window.screenTop
10 網頁正文部分左:window.screenLeft
11 屏幕分辨率的高:window.screen.height
12 屏幕分辨率的寬:window.screen.width
13 屏幕可用工作區高度:window.screen.availHeight
14 屏幕可用工作區寬度:window.screen.availWidth
15
16
17 HTML精確定位:scrollLeft,scrollWidth,clientWidth,offsetWidth
18 scrollHeight: 獲取對象的滾動高度。
19 scrollLeft:設置或獲取位于對象左邊界和窗口中目前可見內容的最左端之間的距離
20 scrollTop:設置或獲取位于對象最頂端和窗口中可見內容的最頂端之間的距離
21 scrollWidth:獲取對象的滾動寬度
22 offsetHeight:獲取對象相對于版面或由父坐標 offsetParent 屬性指定的父坐標的高度
23 offsetLeft:獲取對象相對于版面或由 offsetParent 屬性指定的父坐標的計算左側位置
24 offsetTop:獲取對象相對于版面或由 offsetTop 屬性指定的父坐標的計算頂端位置
25 event.clientX 相對文檔的水平座標
26 event.clientY 相對文檔的垂直座標
27 event.offsetX 相對容器的水平坐標
28 event.offsetY 相對容器的垂直坐標
29 document.documentElement.scrollTop 垂直方向滾動的值
30 event.clientX+document.documentElement.scrollTop 相對文檔的水平座標+垂直方向滾動的量
31
32 IE,FireFox 差異如下:
33
34 IE6.0、FF1.06+:
35
36 clientWidth = width + padding
37
38 clientHeight = height + padding
39
40 offsetWidth = width + padding + border
41
42 offsetHeight = height + padding + border
43
44 IE5.0/5.5:
45 clientWidth = width - border
46
47 clientHeight = height - border
48
49 offsetWidth = width
50
51 offsetHeight = height
52
53 (需要提一下:CSS中的margin屬性,與clientWidth、offsetWidth、clientHeight、offsetHeight均無關)
?
轉載于:https://www.cnblogs.com/sirius-cg/archive/2012/05/18/2507599.html
總結
以上是生活随笔為你收集整理的JS获取屏幕浏览器网页高度和宽度属性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 排序算法概述
- 下一篇: javascript数字验证(转)