
使用window.outerWidth和window.outerHeight事件在JavaScript中获取窗口大小,当浏览器调整大小时。
示例
您可以尝试运行以下代码来使用事件检查浏览器窗口大小 −
<!DOCTYPE html>
<html>
<head>
<script>
function resizeFunction() {
var val = "Window Width=" + window.outerWidth + ", Window Height="
+ window.outerHeight;
document.getElementById("test").innerHTML = val;
}
</script>
</head>
<body onresize = "resizeFunction()">
<p>Resize browser window and check the window (browser window)
height and width again.</p>
<p id = "test"> </p>
</body>
</html>

