您当前的位置: 首页 > 

彭世瑜

暂无认证

  • 2浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

获取浏览器窗口高度和宽度兼容IE

彭世瑜 发布时间:2019-11-18 19:54:02 ,浏览量:2

代码如下

// 浏览器窗口的宽度,兼容 Internet Explorer 8, 7, 6, 5
function getClientWidth(){
    return window.innerWidth 
    || document.documentElement.clientWidth 
    || document.body.clientWidth;
}

// 浏览器窗口的高度,兼容 Internet Explorer 8, 7, 6, 5
function getClientHeight(){
    return window.innerHeight 
    || document.documentElement.clientHeight 
    || document.body.clientHeight; 
}


console.log(getClientWidth());
console.log(getClientHeight());

参考 JavaScript Window - 浏览器对象模型

关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.2236s