<html>
<body onresize="myFunction()">
<p>请尝试调整浏览器窗口的大小以显示窗口的高度和宽度。</p>
<p id="demo"></p>
<p><b>注释:</b>本例在 IE8 及更早版本中无法正常工作。IE8 及更早版本不支持 window 对象的 outerWidth/outerHeight 属性。</p>
<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>
</body>
</html>