首页 > 其他 > 详细

获取浏览器可视区域宽高

时间:2018-08-02 00:50:34      阅读:138      评论:0      收藏:0      [点我收藏+]
 1     /**
 2      * 获取浏览器可视区域宽度
 3      */
 4     function getViewPortOffset() {
 5         if (window.innerWidth) {
 6             return {
 7                 w: window.innerWidth,
 8                 h: window.innerHeight
 9             }
10         } else if (document.compatMode = "BackCompat") {
11             return {
12                 w: document.body.clientWidth,
13                 h: document.body.clientHeigth
14             }
15         } else {
16             return {
17                 w: document.documentElement.clientWidth,
18                 h: document.documentElement.clientHeight
19             }
20         }
21     }
22     console.log(getViewPortOffset());
23     

 

获取浏览器可视区域宽高

原文:https://www.cnblogs.com/lprosper/p/9404534.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!