HTMLMediaElement: error イベント
error
イベントは、リソースがエラーのために読み込めなかったときに発生します (例えば、ネットワーク接続の問題など)。
バブリング | なし |
---|---|
キャンセル可能 | いいえ |
インターフェイス | Event |
イベントハンドラープロパティ | onerror (en-US) |
例
const video = document.querySelector('video');
const videoSrc = 'https://path/to/video.webm';
video.addEventListener('error', () => {
console.error(`Error loading: ${videoSrc}`);
});
const source = document.createElement('source');
source.setAttribute('src', videoSrc);
source.setAttribute('type', 'video/webm');
video.appendChild(source);
仕様書
仕様書 | 状態 |
---|---|
HTML Living Standard | 現行の標準 |
HTML5 | 勧告 |
ブラウザーの対応
BCD tables only load in the browser