<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><b>注意:</b>此例在 IE8 及更早版本中无法正常工作。IE8 及更早版本不支持 window 对象的 outerWidth/outerHeight 属性。</p>
</body>
</html>