js 如何获取浏览器的高度
发布时间:2025-05-25 05:34:15 发布人:远客网络
一、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
二、JS获取body的高度
1、document.body.clientWidth;//网页可见区域宽
2、document.body.clientHeight;//网页可见区域高
3、document.body.offsetWidth;//网页可见区域宽(包括边线的宽)
4、document.body.offsetHeight;//网页可见区域高(包括边线的高)
5、document.body.scrollWidth;//网页正文全文宽
6、window.screen.availHeight;//屏幕可用工作区高度
7、window.screen.availWidth;//屏幕可用工作区宽度
8、alert($(document.body).outerWidth(true));//浏览器时下窗口文档body的总宽度包括border padding margin
9、alert($(document.body).width());//浏览器时下窗口文档body的高度
1、alert($(window).height());//浏览器时下窗口可视区域高度
2、alert($(document).height());//浏览器时下窗口文档的高度
3、alert($(document.body).height());//浏览器时下窗口文档body的高度
4、alert($(document.body).outerHeight(true));//浏览器时下窗口文档body的总高度包括border padding margin
5、alert($(window).width());//浏览器时下窗口可视区域宽度
6、alert($(document).width());//浏览器时下窗口文档对于象宽度
7、alert($(document).scrollTop());//获取滚动条到顶部的垂直高度
8、alert($(document).scrollLeft());//获取滚动条到左边的垂直宽度
三、js网页如何获取手机屏幕宽度
1、"屏幕宽高为:"+screen.width+"*"+screen.height;
2、网页可见区域宽:document.body.clientWidth
3、网页可见区域高:document.body.clientHeight
4、网页可见区域宽:document.body.offsetWidth(包括边线的宽)
5、网页可见区域高:document.body.offsetHeight(包括边线的宽)
6、网页正文全文宽:document.body.scrollWidth
7、网页正文全文高:document.body.scrollHeight
8、网页被卷去的高:document.body.scrollTop
9、网页被卷去的左:document.body.scrollLeft
10、网页正文部分上:window.screenTop
11、网页正文部分左:window.screenLeft
12、屏幕分辨率的高:window.screen.height
13、屏幕分辨率的宽:window.screen.width
14、屏幕可用工作区高度:window.screen.availHeight
15、屏幕可用工作区宽度:window.screen.availWidth
16、HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth
17、scrollHeight:获取对象的滚动高度。
18、scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
19、scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
20、scrollWidth:获取对象的滚动宽度
21、offsetHeight:获取对象相对于版面或由父坐标 offsetParent属性指定的父坐标的高度
22、offsetLeft:获取对象相对于版面或由 offsetParent属性指定的父坐标的计算左侧位置
23、offsetTop:获取对象相对于版面或由 offsetTop属性指定的父坐标的计算顶端位置
24、event.clientX相对文档的水平座标
25、event.clientY相对文档的垂直座标
26、event.offsetX相对容器的水平坐标
27、event.offsetY相对容器的垂直坐标
28、document.documentElement.scrollTop垂直方向滚动的值
29、event.clientX+document.documentElement.scrollTop相对文档的水平座标+垂直方向滚动的量