码迷,mamicode.com
首页 > 其他好文 > 详细

获取浏览器可视区域宽高

时间:2018-08-02 01:47:22      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:bsp   win   console   height   ret   mod   document   lse   宽高   

 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     

 

获取浏览器可视区域宽高

标签:bsp   win   console   height   ret   mod   document   lse   宽高   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!