HTMLMediaElement: error event

翻译不完整。 请帮助我们翻译这篇文章!

事件 error 会在因为一些错误(如网络连接错误)导致无法加载资源的时候触发。

起泡
可取消
接口 Event
事件处理器属性 onerror

示例

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

video.addEventListener('error', () => {
  console.error(`Error loading: ${videoSrc}`);
});

video.setAttribute('src', videoSrc);

规范

规范 状态
HTML Living Standard Living Standard
HTML5 Recommendation

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
error eventChrome Full support YesEdge Full support ≤79Firefox Full support YesIE ? Opera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android ? Safari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

更多