ondurationchange event

ondurationchange event The event object

JavaScript is performed when the length of the video changes:

<video ondurationchange="myFunction()">

Try it out . . .

More examples are included at the bottom of this article.


Definitions and usages

The ondurationchange event is triggered when the length of the video/audio/video changes.

Note: When the video/audio/video has been loaded, the length of the video/audio (audio/video) is modified from "NaN" to the time it is being.

During the video/audio/video loading process, the events are triggered in the following order:

  1. onloadstart
  2. ondurationchange
  3. onloadedmetadata
  4. onloadeddata
  5. onprogress
  6. oncanplay
  7. oncanplaythrough

Browser support

The numbers in the table support the version number of the first browser for the event.

Event
ondurationchange Yes 9.0 Yes Yes Yes


Grammar

In HTML:

< element ondurationchange=" myScript "> Give it a try

In JavaScript:

object .ondurationchange=function(){ myScript }; Give it a try

In JavaScript, use the addEventListener() method:

object .addEventListener("durationchange", myScript ); Give it a try

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions of IE.


Technical details
Whether to support bubbling: No
Can I cancel: No
Types of events: Event
Supported HTML tags: <audio>, <video>


ondurationchange event

More instances

JavaScript is performed when audio starts loading:

<audio ondurationchange="myFunction()">

Try it out . . .


ondurationchange event The event object