HTML onstalled Event Attribute


The HTML onstalled event attribute is used to specify a script that will be executed when the browser is trying to get media data, but the data is not available.

This event can be caused by a number of factors, such as a slow network connection, a problem with the media server, or a corrupted media file.

The onstalled event can be used to notify the user of the problem, or to take other corrective action, such as retrying the download or switching to a different media source.

The onstalled event attribute can be used on any HTML element that supports media, such as the <video> and <audio> elements.

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

<video onstalled="myScript()">
  <source src="myVideo.mp4" type="video/mp4">

The myScript() function will be executed when the browser is trying to get the media data for the myVideo.mp4 file, but the data is not available.

Here is an example of a simple myScript() function:

function myScript() {
  alert("The video is stalled. Please try again later.");

This function will display an alert message to the user when the video stalls.

The onstalled event attribute is a useful tool for handling media streaming errors. By using this event attribute, you can notify the user of the problem and take corrective action to minimize the disruption to the user experience.


<element onstalled="script">


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


<!DOCTYPE html>

<video controls onstalled="myFunction()">
<source src="sample.mp4" type="video/mp4">
Your browser does not support HTML5 video.

function myFunction() {
alert("EXAMPLE: Data of this media not available");


Browser Support

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

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 14th October 2023