Open In App

HTML onemptied Attribute

Last Updated : 08 Aug, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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: 

  • <audio> 
  • <video>

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:
 

HTML




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

  • Before the playlist is empty: 
     

  •  
  • After the playlist is empty: 
     

  •  

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

  • Google Chrome 20.0
  • Firefox 25.0
  • Safari 6.0
  • Opera 15.0

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads