Advertisement
Home Open Editor ❯

HTML Audio/Video DOM durationchange Event

Example

//Accessing the element
var vid = document.getElementById("myVideo");

//Creating a function
vid.ondurationchange = function() {
    alert("The video duration has changed");
};

Try this code ❯

Meaning

The durationchange event run when the duration of the audio/video is changed.


Standard Syntax

HTML:

<element ondurationchange="script">

JavaScript:

object.ondurationchange=function(){myScript};

JavaScript, using the addEventListener() method::

object.addEventListener("durationchange", myScript);


Advertisement

Technical Details

Type Description
Supported HTML tags: <audio> and <video>
Supported JavaScript objects: Audio, Video
Home Open Editor ❯
Advertisement