The window resize event occurs whenever the size of the browser window gets changed. We can listen to the resize event in two ways:
- Using onresize event
- Using Resize Observer API
Method 1: Using resize event: We can add an event listener to the body element which fires every time when the window size is resized.
Method 2: Using ResizeObserver API: We can use the latest ResizeObserver API to listen the window resize event. This API is not fully supported.
- Display a Resized and Cropped Image using CSS
- Web Window API | Window locationbar property
- Web Window API | Window scrollbars property
- Web Window API | DOM Window fullscreen property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.