studysuper
2016-03-31 18:15
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript">
var w=document.body.clientWidth;
var h=document.body.clientHeight;
document.write(w+"*"+h+"<br>");
var w=document.documentElement.clientWidth;
var h=document.documentElement.clientHeight;
document.write(w+"*"+h+"<br>");
var w=document.body.clientWidth || document.documentElement.clientWidth;
var h=document.body.clientHeight || document.documentElement.clientHeight;
document.write(w+"*"+h+"<br>");
var w=window.innerWidth;
var h=window.innerHeight;
document.write(w+"*"+h+"<br>");
</script>
</body>
</html>
document.body.clientWidth是指body的可视窗口,document.documentElement.clientWidth是指html层的可视窗口,不同的浏览器之间他们的边距是不一样的。
JavaScript进阶篇
468196 学习 · 21891 问题
相似问题