JavaScript 中浏览器窗口调整大小时发生的事件是什么?

htmljavascriptprogramming scripts

使用 JavaScript 中的 window.outerWidthwindow.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>

相关文章