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