<html>
<head>
<script>
function myFunction() {
var w = window.outerWidth;
var h = window.outerHeight;
var txt = "Window size: width=" + w + ", height=" + h;
document.getElementById("demo").innerHTML = txt;
}
</script>
</head>
<body onresize="myFunction()">
<p>尝试调整浏览器窗口的大小。</p>
<p id="demo"> </p>
<p>注意:此示例在 IE8 及更早版本中无法正常运行。 IE8 及更早版本不支持 window 对象的 outerWidth/outerHeight 属性。</p>
</body>
</html>