MDN self-hosted library · e01.org

HTMLVideoElement: resize event

HTML DOM

HTML DOM

The resize event of the HTMLVideoElement interface fires when one or both of the videoWidth and videoHeight properties have just been updated.

This event is not cancelable but may bubble.

Syntax

Use the event name in addEventListener():

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

Alternatively, assign to the event handler property of the interface:

onresize = (event) => { }

Event type

A generic Event.

Examples

<video id="media" src="https://example.com/video.mp4"></video>
const el = document.getElementById("media");
el.addEventListener("resize", () => {
  console.log("The size of the video element has changed!");
});

Specifications

Browser compatibility

See also

  • HTMLVideoElement.videoHeight
  • HTMLVideoElement.videoWidth