首页 新闻 会员 周边

关于文档高度有些不解?????

0
悬赏园豆:5 [已解决问题] 解决于 2016-03-30 18:19

oMask.style.width = Math.max( document.body.offsetHeight,document.documentElement.clientHeight ) + 'px'

document.documentElement.clientHeight:如果内容没有可视区高,那么文档高就是可视区这句话如何理解??

 

document.body.offsetHeight和document.documentElement.clientHeight (文档元素可视区域高度)怎么理解??

hduhdc的主页 hduhdc | 初学一级 | 园豆:106
提问于:2016-03-21 08:42
< >
分享
最佳答案
0

看看这个

http://www.cnblogs.com/yuteng/articles/1894578.html

收获园豆:5
Rich.T | 老鸟四级 |园豆:3440 | 2016-03-21 10:09

document.body.offsetHeight并不表示文档的高度

hduhdc | 园豆:106 (初学一级) | 2016-03-21 15:15

我看了你写的我感觉和我验证的为哈对不上。

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>
window.onload = function() {

//offsetHeight
alert(document.body.style.height);
alert( document.body.offsetHeight );

//ie : 如果内容没有可视区高,那么文档高就是可视区
//alert( document.documentElement.offsetHeight );
alert(document.body.scrollHeight);
//alert( document.body.offsetHeight );
//alert( document.body.clientWidth );

}
</script>
</head>

<body style="width:2000px;height:2000px;border:1px red solid">
dsdfds
</body>
</html>

 

这是我的验证代码,(document.body.scrollHeight);为2000火狐下

alert(document.body.style.height);是2000
alert( document.body.offsetHeight );为2002

后面的两个结果基本一致,但是scrollWidth不对的,并没有向你说的那样加上边框和横向滚动条

hduhdc | 园豆:106 (初学一级) | 2016-03-21 15:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册