W3cubDocs

/Web APIs

VisualViewport: resize event

The resize event of the VisualViewport interface is fired when the visual viewport is resized.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js

addEventListener("resize", (event) => {});

onresize = (event) => {};

Event type

A generic Event.

Examples

You can use the resize event in an addEventListener method:

js

visualViewport.addEventListener("resize", () => {
  // …
});

Or use the onresize event handler property:

js

visualViewport.onresize = () => {
  // …
};

Specifications

Browser compatibility

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 62
61The onresize event handler property is not supported.
79 91 No 49
48The onresize event handler property is not supported.
13 62
61The onresize event handler property is not supported.
62
61The onresize event handler property is not supported.
68 46
45The onresize event handler property is not supported.
13 8.0

See also

© 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