CSS Portal

HTML onemptied Event Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
onemptied
HTML Event AttributeThis event attribute is supported by all modern browsers.
Updated 14th October 2023

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
Open in editor

Browser Support

The following information will show you the current browser support for the HTML onemptied event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.

This event attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee