问答详情
源自:9-18 浏览器窗口可视区域大小

为什么都是0呢

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript">
var w=document.documentElement.clientWidth||document.body.clientWidth;
var h=document.documentElement.clientHeight||document.body.clientHeight;
document.write(w+"*"+h+"<br>")

var w=document.documentElement.clientHeight;
var h=document.documentElement.clientWidth;
document.write(w+"*"+h+"<br>")

var w=window.innerWidth;
var h=window.innerHeight;
document.write(w+"*"+h+"<br>")

var w=document.body.clientWidth;
var h=document.body.clientHeight;
document.write(w+"*"+h)
</script>
</body>
</html>

提问者:小尼采 2016-03-25 10:17

个回答

  • ppfei
    2016-03-25 15:44:42
    已采纳

    页面刷新一下就好了