Open In App

HTML onemptied Attribute

The HTML onemptied attribute is used to trigger an event when the media encounters some fatal error or the media file becomes unavailable or the media playlist is empty.

Supported Tags: 



Syntax:

<element onemptied="scriptFunction()"> 

Attribute value: This attribute contains single value script which works when media 
is empty by using the onemptied attribute. This video or audio files are supported by <audio> and <video> tags.



Example:
 




<!DOCTYPE html>
<html>
 
<body>
    <center>
        <h1>GeeksForGeeks</h1>
 
        <h2>HTML onemptied attribute</h2>
    </center>
 
    <video width="320" height="240"
        controls onemptied="onEmptied()">
        <source src="videoFile.mp4" type="video/mp4">
    </video>
     
    <script>
        function onEmptied() {
            alert(" Video playlist is empty!");
        }
    </script>
</body>
 
</html>

Output:

Supported Browsers: The browsers supported by HTML onemptied attribute are listed below:

Article Tags :