HTML onabort Event Attribute


The onabort HTML event attribute triggers a JavaScript function when the loading of an audio or video file is aborted. This can happen for a number of reasons, such as the user clicking the "Cancel" button, or the network connection being lost.

This event is different from the onerror event, which is triggered when an error occurs while loading the media file. The onabort event is specifically triggered when the user aborts the loading process.

To use the onabort event, simply add the attribute to the audio or video element that you want to monitor. The value of the attribute should be the name of the JavaScript function that you want to be called when the event is triggered.

Here is an example of how to use the onabort event:

<video onabort="myAbortFunction()">
  <source src="my_video.mp4" type="video/mp4">

The myAbortFunction() function will be called if the user clicks the "Cancel" button while the video is loading.

You can use the onabort event to perform a variety of tasks, such as:

  • Displaying a message to the user informing them that the loading process was aborted.
  • Logging the event for debugging purposes.
  • Taking other actions, such as stopping a loading spinner or hiding a progress bar.

The onabort event is a useful tool for handling unexpected interruptions to the loading of audio and video files.


<element onabort="script">


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


Currently no example, coming soon.

Browser Support

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

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

Last updated by CSSPortal on: 14th October 2023