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

兼容的可视区高度和宽度

时间:2015-08-08 22:41:40      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

function viewWidth(){
    return window.innerWidth || document.documentElement.clientWidth;
}
function viewHeight(){
    return window.innerHeight || document.documentElement.clientHeight;
}

 document.body.clientWidth ==> BODY对象宽度
 document.body.clientHeight ==> BODY对象高度
 document.documentElement.clientWidth ==> 可见区域宽度
 document.documentElement.clientHeight ==> 可见区域高度

  innerWidth&innerHeight

只读属性,声明了窗口的文档显示区的高度和宽度,以像素计。
这里的宽度和高度不包括菜单栏、工具栏以及滚动条等的高度。

兼容的可视区高度和宽度

标签:

原文地址:http://www.cnblogs.com/ntscshen/p/4713912.html

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