HTMLMediaElement:abort 事件
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
abort 事件會在資源未完全載入,且非因錯誤導致時觸發。
此事件不可取消且不會冒泡。
語法
在 addEventListener() 等方法中使用事件名稱,或設定事件處理器屬性。
js
addEventListener("abort", (event) => { })
onabort = (event) => { }
事件類型
通用的 Event。
範例
js
const video = document.querySelector("video");
const videoSrc = "https://example.org/path/to/video.webm";
video.addEventListener("abort", () => {
console.log(`中止載入:${videoSrc}`);
});
const source = document.createElement("source");
source.setAttribute("src", videoSrc);
source.setAttribute("type", "video/webm");
video.appendChild(source);
規範
| Specification |
|---|
| HTML> # event-media-abort> |
| HTML> # handler-onabort> |