onresize Event
Example
Call a function when the browser window is resized:
More "Try it Yourself" examples below.
Description
The onresize event occurs when the browser window has been resized.
Tip: To get the size of an element, use the clientWidth, clientHeight, innerWidth, innerHeight, outerWidth, outerHeight, offsetWidth and/or offsetHeight properties.
Browser Support
| Yes | Yes | Yes | Yes | Yes |
Syntax
In JavaScript, using the addEventListener() method:
Technical Details
| Bubbles: | No |
|---|---|
| Cancelable: | No |
| Event type: | UiEvent if generated from a user interface, Event otherwise |
| HTML tags: | <body> |
| DOM Version: | Level 2 Events |
More Examples
Example
Using the addEventListener() method to attach the "resize" event on the window object.