HTMLMediaElement: abort event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The abort event is fired when the resource was not fully loaded, but not as the result of an error.

This event is not cancelable and does not bubble.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("abort", (event) => { })

onabort = (event) => { }

Event type

A generic Event.

Examples

The following example starts loading one video resource, then starts another load before the first resource has finished. If the first resource is still loading when load() is called again, the abort event fires.

js
const video = document.querySelector("video");
const firstVideoSrc = "https://example.org/path/to/video.webm";
const secondVideoSrc = "https://example.org/path/to/another-video.webm";

video.addEventListener("abort", () => {
  console.log(`Aborted loading: ${firstVideoSrc}`);
});

video.src = firstVideoSrc;
video.load();

setTimeout(() => {
  video.src = secondVideoSrc;
  video.load();
}, 1000);

Specifications

Specification
HTML
# event-media-abort
HTML
# handler-onabort

Browser compatibility

See also