html tutorial - ondurationchange Attribute in HTML - html5 - html code - html form

ondurationchange attribute in html

Learn html - html tutorial - ondurationchange attribute in html - html examples - html programs

  • The ondurationchange attribute triggers when duration change in a video/audio.
  • Default value of duration is “NaN” if it changed to a time duration the ondurationchange event occurs.

Syntax for ondurationchange attribute in HTML:

<audio ondurationchange="script">

Applies To:

Elements Attribute
<audio> ondurationchange
<video> ondurationchange

Attribute Values:

Value Description
script The script to be run on ondurationchange

Sample Coding for ondurationchange Attribute in HTML:

Tryit<!DOCTYPE html>
          <title>Wikitechy ondurationchange attribute</title>
        <audio controls ondurationchange="durationChange(this)">
        <source src="welcome.wav" type="audio/wav">
        <source src="welcome.mp3" type="audio/mp3">
        function durationChange (obj)
             alert("Total Duration of Audio in Seconds :" + obj.duration);

Code Explanation for ondurationchange Attribute in HTML:

 ondurationchange Attribute Code Explanation

  1. ondurationchange attribute used to trigger an event when duration of the audio changed.
  2. “this” keyword used to pass the audio object to the JavaScript function.
  3. durationChange JavaScript function got the audio object as “obj”.
  4. obj.duration used to get the duration of the audio object.

Output for ondurationchange Attribute in HTML:

ondurationchange Attribute Tag Output

  1. The output shows "Total Duration of Audio in Seconds " in an alert message.

Browser Support for ondurationchange Attribute in HTML:

Yes 9.0 Yes Yes Yes

Related Searches to ondurationchange Attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.