美文网首页
关于js获取屏幕高度和宽度( window.document.b

关于js获取屏幕高度和宽度( window.document.b

作者: 静_c540 | 来源:发表于2018-07-04 17:05 被阅读0次

一上图(PC端)为例,

A区域 表示的网页的区域(屏幕下面虚线地方表示的是网页可以滑动的区域):

widow.document.body.offsetWidth

window.document.body.offsetHeight。

B区域 表示的是可用区域(有网上的叫做空白区域)也就是显示的屏幕 除掉上面的工具栏(浏览器的标签)和下面的工具栏(电脑的菜单)。注意的是滑动栏是属于可用区域的:          

 window.screen.availWidth

window.screen.availHeight。

C区域 表示的是显示器的宽和高,也就是电脑的分辨率 

window.screen.Width

window.screen.Height。

所以window.screen.Width= window.screen.availWidth

假如是移动设备,由于没有显示滑动条, 所以window.screen.Width= window.screen.availWidth=widow.document.body.offsetWidth,

至于高度的话含义和电脑端是一样的。

相关文章

网友评论

      本文标题:关于js获取屏幕高度和宽度( window.document.b

      本文链接:https://www.haomeiwen.com/subject/phfyuftx.html