在 JavaScript 中调整浏览器窗口时应该采用哪种事件?
在 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>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP