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.

资源没有被完全加载时就会触发 abort 事件,但错误不会触发该事件。

Bubbles No
Cancelable No
Interface Event
Event handler property onabort

示例

js
const video = document.querySelector("video");
const videoSrc = "https://path/to/video.webm";

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

const source = document.createElement("source");
source.setAttribute("src", videoSrc);
source.setAttribute("type", "video/webm");

video.appendChild(source);

规范

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

浏览器兼容性

BCD tables only load in the browser

参阅