JavaScript中onresize事件的用途是什么?
窗口调整大小时,会触发resize事件。在JavaScript中使用 window.outerWidth和window.outerHeight事件以在浏览器调整大小时获取窗口大小。
示例
你可以尝试运行以下代码来使用JavaScript中的onresize事件。
<!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