``` More examples are included at the bottom of"> ``` More examples are included at the bottom of" />
Easy Tutorial
❮ Prop Style Margin Prop Hidden Type ❯

ondurationchange Event

Event Object

Example

Execute JavaScript when the duration of the video changes:

<video ondurationchange="myFunction()">

More examples are included at the bottom of this page.


Definition and Usage

The ondurationchange event is triggered when the duration of the video/audio (audio/video) changes.

Note: When the video/audio (audio/video) has been loaded, the duration of the video/audio (audio/video) changes from "NaN" to the actual duration.

The sequence of events during the loading of the video/audio (audio/video) is as follows:


Browser Support

The numbers in the table specify the first browser version that fully supports the event.

Event Chrome IE Firefox Safari Opera
ondurationchange Yes 9.0 Yes Yes Yes

Syntax

In HTML:

In JavaScript:

In JavaScript, using the addEventListener() method:

Note: Internet Explorer 8 and earlier versions do not support the addEventListener() method.


Bubbles: No
Cancelable: No
--- ---
Event Type: Event
--- ---
Supported HTML Tags: <audio>, <video>
--- ---

More Examples

Example

Execute JavaScript when the audio starts loading:

<audio ondurationchange="myFunction()">

❮ Prop Style Margin Prop Hidden Type ❯