The resize
event of the VisualViewport
interface is fired when the visual viewport is resized.
The resize
event of the VisualViewport
interface is fired when the visual viewport is resized.
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("resize", (event) => {}); onresize = (event) => {};
A generic Event
.
You can use the resize
event in an addEventListener
method:
js
visualViewport.addEventListener("resize", () => { // … });
Or use the onresize
event handler property:
js
visualViewport.onresize = () => { // … };
Specification |
---|
CSSOM View Module # eventdef-window-resize |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
resize_event |
6261Theonresize event handler property is not supported. |
79 | 91 | No | 4948Theonresize event handler property is not supported. |
13 | 6261Theonresize event handler property is not supported. |
6261Theonresize event handler property is not supported. |
68 | 4645Theonresize event handler property is not supported. |
13 | 8.0 |
© 2005–2023 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