
IE中:
documentbodyclientWidth ==> BODY对象宽度
documentbodyclientHeight ==> BODY对象高度
documentdocumentElementclientWidth ==> 可见区域宽度
documentdocumentElementclientHeight ==> 可见区域高度
FireFox中:
documentbodyclientWidth ==> BODY对象宽度
documentbodyclientHeight ==> BODY对象高度
documentdocumentElementclientWidth ==> 可见区域宽度
documentdocumentElementclientHeight ==> 可见区域高度
Opera中:
documentbodyclientWidth ==> 可见区域宽度
documentbodyclientHeight ==> 可见区域高度
documentdocumentElementclientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)
documentdocumentElementclientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
没有定义W3C的标准,则
IE为:
documentdocumentElementclientWidth ==> 0
documentdocumentElementclientHeight ==> 0
FireFox为:
documentdocumentElementclientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)
documentdocumentElementclientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
Opera为:
documentdocumentElementclientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)
documentdocumentElementclientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
网页可见区域宽: documentbodyclientWidth
网页可见区域高: documentbodyclientHeight
网页可见区域宽: documentbodyoffsetWidth (包括边线的宽)
网页可见区域高: documentbodyoffsetHeight (包括边线的高)
网页正文全文宽: documentbodyscrollWidth
网页正文全文高: documentbodyscrollHeight
网页被卷去的高: documentbodyscrollTop
网页被卷去的左: documentbodyscrollLeft
网页正文部分上: windowscreenTop
网页正文部分左: windowscreenLeft
屏幕分辨率的高: windowscreenheight
屏幕分辨率的宽: windowscreenwidth
屏幕可用工作区高度: windowscreenavailHeight
屏幕可用工作区宽度: windowscreenavailWidth
HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置
offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置
eventclientX 相对文档的水平座标
eventclientY 相对文档的垂直座标
eventoffsetX 相对容器的水平坐标
eventoffsetY 相对容器的垂直坐标
documentdocumentElementscrollTop 垂直方向滚动的值
eventclientX+documentdocumentElementscrollTop 相对文档的水平座标+垂直方向滚动的量
示例:
var winWidth = 0;var winHeight = 0;
function findDimensions() //函数:获取尺寸
{
//获取窗口宽度
if (windowinnerWidth)
winWidth = windowinnerWidth;
else if ((documentbody) && (documentbodyclientWidth))
winWidth = documentbodyclientWidth;
//获取窗口高度
if (windowinnerHeight)
winHeight = windowinnerHeight;
else if ((documentbody) && (documentbodyclientHeight))
winHeight = documentbodyclientHeight;
//通过深入Document内部对body进行检测,获取窗口大小
if (documentdocumentElement && documentdocumentElementclientHeight && documentdocumentElementclientWidth)
{
winHeight = documentdocumentElementclientHeight;
winWidth = documentdocumentElementclientWidth;
}
//结果输出至两个文本框
documentform1availHeightvalue= winHeight;
documentform1availWidthvalue= winWidth;
}
findDimensions();
//调用函数,获取数值
windowonresize=findDimensions;
var win_w = $(window)width();//获取宽度
var win_h = $(window)height();//获取高度
如果你想要匹配高度,那么,就是页面刚刚打开其实没有数据,是等页面打开,计算了屏幕高度之后,再根据每条数据的高度计算出条数,再利用ajax的异步传输去读取列表,然后用JS呈现在手机网页中的。
1、documentbodyclientWidth;//网页可见区域宽
2、documentbodyclientHeight;//网页可见区域高
3、documentbodyoffsetWidth;//网页可见区域宽(包括边线的宽)
4、documentbodyoffsetHeight;//网页可见区域高(包括边线的高)
5、documentbodyscrollWidth;//网页正文全文宽
6、windowscreenavailHeight;//屏幕可用工作区高度
7、windowscreenavailWidth;//屏幕可用工作区宽度
8、alert($(documentbody)outerWidth(true));//浏览器时下窗口文档body的总宽度 包括border padding margin
9、alert($(documentbody)width());//浏览器时下窗口文档body的高度
扩展资料:
1、alert($(window)height()); //浏览器时下窗口可视区域高度
2、alert($(document)height()); //浏览器时下窗口文档的高度
3、alert($(documentbody)height());//浏览器时下窗口文档body的高度
4、alert($(documentbody)outerHeight(true));//浏览器时下窗口文档body的总高度 包括border padding margin
5、alert($(window)width()); //浏览器时下窗口可视区域宽度
6、alert($(document)width());//浏览器时下窗口文档对于象宽度
7、alert($(document)scrollTop()); //获取滚动条到顶部的垂直高度
8、alert($(document)scrollLeft()); //获取滚动条到左边的垂直宽度
需要准备的材料分别有:电脑、chrome浏览器、html编辑器。
1、首先,打开html编辑器,新建html文件,例如:indexhtml,并引入jquery。
2、其次在indexhtml中的<script>标签,输入js代码:
documentbodyinnerText = $(window)height();
3、浏览器运行indexhtml页面,此时会通过jquery获取到窗口高度“743”并打印出。
以上就是关于如何用JS动态获取浏览器的宽高全部的内容,包括:如何用JS动态获取浏览器的宽高、js如何根据不同屏幕的大小,获得页面高度,自动调整列表高度、JS获取body的高度等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)