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

获取屏幕的宽高

时间:2017-10-20 18:23:42      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:pre   width   宽高   mode   func   define   turn   class   cli   

function client(){
    if(window.innerHeight !== undefined){
        return {
            "width": window.innerWidth,
            "height": window.innerHeight
        }
    }else if(document.compatMode === "CSS1Compat"){
        return {
            "width": document.documentElement.clientWidth,
            "height": document.documentElement.clientHeight
        }
    }else{
        return {
            "width": document.body.clientWidth,
            "height": document.body.clientHeight
        }
    }
}

 

获取屏幕的宽高

标签:pre   width   宽高   mode   func   define   turn   class   cli   

原文地址:http://www.cnblogs.com/xlj-code/p/7700364.html

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