HTMLMediaElement: sự kiện abort
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.
Sự kiện abort được kích hoạt khi tài nguyên chưa được tải đầy đủ nhưng không phải do lỗi.
Sự kiện này không thể hủy và không bong bóng.
Cú pháp
Sử dụng tên sự kiện trong các phương thức như addEventListener() hoặc đặt thuộc tính xử lý sự kiện.
js
addEventListener("abort", (event) => { })
onabort = (event) => { }
Kiểu sự kiện
Một Event chung chung.
Ví dụ
js
const video = document.querySelector("video");
const videoSrc = "https://example.org/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);
Đặc tả kỹ thuật
| Specification |
|---|
| HTML> # event-media-abort> |
| HTML> # handler-onabort> |