<video controls width="250"></video>
<button id="loadAndAbort">Load and abort video</button>
<pre id="log"></pre>HTMLMediaElement: abort event / notebook
HTMLMediaElement: abort event
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
video,
button,
pre {
display: block;
margin-block: 1rem;
}const video = document.querySelector("video");
const loadAndAbortButton = document.querySelector("#loadAndAbort");
const log = document.querySelector("#log");
video.addEventListener("abort", () => {
log.textContent += "Video loading aborted\n";
});
loadAndAbortButton.addEventListener("click", () => {
log.textContent = "Loading video...\n";
video.src = `/shared-assets/videos/flower.webm?nocache=${Date.now()}`;
video.load();
setTimeout(() => {
video.removeAttribute("src");
video.load();
}, 50);
});