Home  >  Article  >  Web Front-end  >  In JavaScript, when the browser window is resized, which event is this?

In JavaScript, when the browser window is resized, which event is this?

王林
王林forward
2023-09-05 11:25:071087browse

In JavaScript, when the browser window is resized, which event is this?

Use the window.outerWidth and window.outerHeight events to get the window size in JavaScript when the browser resizes.

Example

You can try running the following code to check the browser window size using events −

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

The above is the detailed content of In JavaScript, when the browser window is resized, which event is this?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete