获取屏幕可视区域

 1  client: function() {
 2             if(window.innerWidth !== null){ // 最新的浏览器
 3                 return {
 4                     "width": window.innerWidth,
 5                     "height": window.innerHeight
 6                 }
 7             }else if(document.compatMode === 'CSS1Compat'){ // W3C
 8                 return {
 9                     "width": document.documentElement.clientWidth,
10                     "height": document.documentElement.clientHeight
11                 }
12             }
13             return {
14                 "width": document.body.clientWidth,
15                 "height": document.body.clientHeight
16             }
17         }
1 console.log(window.innerWidth, window.innerHeight);
2 console.log(document.documentElement.clientWidth, document.documentElement.clientHeight);
3 console.log(document.body.clientWidth, document.body.clientHeight);

 

posted @ 2019-07-19 00:08  疏影横斜水清浅  阅读(380)  评论(0编辑  收藏  举报