This feature is well established and works across many devices and browser versions. It’s been available across browsers since August 2021.
The resize event of the VisualViewport interface is fired when the visual viewport is resized. This allows you to position elements relative to the visual viewport as it is zoomed, which would normally be anchored to the layout viewport.
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("resize", (event) => { })
onresize = (event) => { }
A generic Event.
See the Visual Viewport API landing page for a usage demo.
| Specification |
|---|
| CSSOM View Module> # eventdef-window-resize> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
resize_event |
6261–62Theonresize event handler property is not supported. |
79 | 91 | 4948–49Theonresize event handler property is not supported. |
13 | 6261–62Theonresize event handler property is not supported. |
68 | 4645–46Theonresize event handler property is not supported. |
13 | 8.0 | 6261–62Theonresize event handler property is not supported. |
13 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport/resize_event