Open In App

HTML onloadeddata Attribute

Last Updated : 10 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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:

html




<!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>


Output:

After:

Example 2:

html




<!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>


Output:

After:

Supported Browsers: 
 

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

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads