在 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