YouTip LogoYouTip

Event Onabort Media

## HTML DOM onabort Event (Media) The `onabort` event occurs when the loading of an audio or video file is aborted (prevented from loading completely). This event is triggered specifically when the media loading process is intentionally or programmatically terminated, rather than when a loading error occurs. --- ## Overview and Usage The `onabort` event is fired when the browser stops fetching media data before it is completely loaded. This typically happens when: * The user explicitly stops the loading process. * The media source is programmatically changed or cleared while loading. * The `load()` method is called on the media element, aborting any current loading process to start a new one. ### Related Media Loading Events To fully monitor the media loading lifecycle, you should also consider these related events: * `onemptied`: Fired when the media list becomes empty (e.g., if the media is reloaded). * `onerror`: Fired when an error occurs during media loading. * `onstalled`: Fired when the browser is trying to get media data, but data is not available. * `onsuspend`: Fired when the browser intentionally stops fetching media data (e.g., to save bandwidth). --- ## Syntax You can register this event in three ways: ### In HTML: ```html ``` ### In JavaScript: ```javascript object.onabort = function() { // Your custom script here }; ``` ### In JavaScript using `addEventListener()`: ```javascript object.addEventListener("abort", myScript); ``` *Note: The event name used in `addEventListener()` is `"abort"`, not `"onabort"`.* --- ## Code Examples ### Example 1: Inline HTML Attribute This example triggers a JavaScript function if the video loading process is aborted. ```html onabort Event Example ``` ### Example 2: Using `addEventListener` This example demonstrates how to attach the `abort` event listener to a video element programmatically. ```html onabort Event Listener

``` --- ## Browser Support The numbers in the table specify the first browser version that fully supports this event. | Event | Chrome | Internet Explorer | Firefox | Safari | Opera | | :--- | :--- | :--- | :--- | :--- | :--- | | **onabort** | Yes | 9.0 | Yes | Yes | Yes | > **Note:** Internet Explorer 11 on Windows 7 does not support the `onabort` event for media elements. Additionally, Internet Explorer 8 and earlier versions do not support the `addEventListener()` method. --- ## Technical Details | Property | Value | | :--- | :--- | | **Bubbles** | No | | **Cancelable** | No | | **Event Type** | Event | | **Supported HTML Tags** | `
← Event OncanplayEvent Oncut β†’