在调整浏览器大小时,可以在JavaScript中使用window.outerWidth和window.outerHeight事件获取窗口的大小。
您可以尝试运行以下代码来处理事件,以检查浏览器窗口大小-
<!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>