问答详情
源自:9-20 网页尺寸offsetHeight

为什么这三种写法得到的答案不同

<!DOCTYPE HTML>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 

</head>

<body>

 <script type="text/javascript">

var w=document.documentElement.offsetWidth;

var h=document.documentElement.offsetHeight;

document.write(w+"***"+h+"<br>");

document.write(document.body.offsetWidth+"<br>");

document.write(document.body.offsetHeight+"<br>");


var x = document.documentElement.offsetWidth    || document.body.offsetWidth;

var y= document.documentElement.offsetHeight    || document.body.offsetHeight;

document.write("宽度:" + x);

document.write("<br>高度:" + y);

</script>

</body>

</html>


提问者:黑豆0 2016-02-23 11:37

个回答

  • qq_好几年不改网名_0
    2016-02-23 16:03:45

    浏览器的兼容性问题