首頁  >  文章  >  web前端  >  在JavaScript中,當瀏覽器視窗調整大小時,這是哪個事件?

在JavaScript中,當瀏覽器視窗調整大小時,這是哪個事件?

王林
王林轉載
2023-09-05 11:25:071086瀏覽

在JavaScript中,當瀏覽器視窗調整大小時,這是哪個事件?

使用window.outerWidthwindow.outerHeight事件在JavaScript中取得視窗大小,當瀏覽器調整大小時。

範例

您可以嘗試執行以下程式碼來使用事件檢查瀏覽器視窗大小 −

<!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>

以上是在JavaScript中,當瀏覽器視窗調整大小時,這是哪個事件?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除