HTML onloadeddata Attribute

The HTML onloadeddata Attribute is a event attribute which occurs when the current frame data is loaded but the next frame’s data is not enough data to play the audio/video.

Syntax:

<element onloadeddata="myScript">

Attribute Value: This attribute contains single value script which works when onloadeddata event attribute call. This attribute is supported by <audio> and <video> tags.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML onloadeddata Attribute
        </title>
    </head>
  
    <body>
        <center>
            <h1 style="color: green;">
                GeeksforGeeks
            </h1>
            <h2>
                HTML onloadeddata Attribute
            </h2>
            <audio controls id="audioId" 
                   onloadeddata="GFGfun()">
                <source src=
                        type="audio/mpeg" />
            </audio>
  
            <script>
                function GFGFun() {
                    alert(
                "Browser has loaded the current frame");
                }
            </script>
        </center>
    </body>
</html>

chevron_right


Output:



After:

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML onloadeddata Attribute
        </title>
    </head>
  
    <body>
        <center>
            <h1 style="color: green;">
                GeeksforGeeks
            </h1>
            <h2>
                HTML onloadeddata Attribute
            </h2>
            <video controls id="VideoId" 
                   width="320" 
                   height="240"
                   onloadeddata="GFGfun()">
              <source src=
                      type="video/mp4" />
          </video>
  
         <script>
          function GFGFun() {
            alert("Browser has loaded the current frame");
          }
            </script>
        </center>
    </body>
</html>

chevron_right


Output:

After:

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.