HTML onemptied Event Attribute

Description

The onemptied HTML event 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.

This event is useful for handling situations where the media cannot be played for some reason, such as when the file is missing, corrupted, or the network connection is lost. It can also be used to handle situations where the media playlist is empty, such as when all of the songs in a playlist have been played.

The onemptied event attribute can be used on the <audio> and <video> elements.

Here is an example of how to use the onemptied event attribute:

<audio onemptied="myFunction()">
  <source src="audio.mp3">
</audio>

The myFunction() function will be called when the audio file encounters an error or becomes unavailable.

Here is an example of what the myFunction() function could do:

function myFunction() {
  // Display an error message to the user.
  alert("The audio file could not be played.");
}

Syntax

<element onemptied="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

Sorry, no example

Browser Support

The following table will show you the current browser support for the HTML onemptied Event Attribute.

Desktop
Edge Chrome Firefox Opera Safari
YesYesYesYesYes
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
YesYesYesYesYesYes

Last updated by CSSPortal on: 14th October 2023