Execute a script when the file is unavailable in HTML?



Use the onemptied attribute in HTML to execute a script when the file is unavailable in HTML or it is empty.

Example

You can try to run the following code to implement the onemptied attribute −

<!DOCTYPE HTML> <html>    <body>       <video width = "300" height = "200" controls onemptied ="display()">          <source src = "/html5/foo.ogg" type = "video/ogg" />          Your browser does not support the video element.       </video>       <script>          function display()          {             alert ("Sorry! Empty playlist!");          }       </script>    </body> </html>
Updated on: 2020-03-03T09:51:09+05:30

215 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements