HTML ondurationchange Attribute

❮ HTML Attributes


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

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


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

Standard Syntax

<element ondurationchange="script">

Browser Support


Applies to:

The ondurationchange attribute can be used on the following element:

Element Attribute
<video> ondurationchange
<video> ondurationchange

Attribute Values

Value Description
script Specifies the script to be run on ondurationchange
❮ HTML Attributes