这篇翻译不完整。请帮忙从英语翻译这篇文章

The WebSocket.onerror property returns the event listener to be called when an error occurs. This is a simple event named "error".

WebSocket.onerror 属性中,你可以定义一个发生错误时执行的回调函数,此事件的事件名为"error"

语法

aWebSocket.onerror = function(event) {
  console.error("WebSocket error observed:", event);
};

An EventListener.

Specifications

Specification Status Comment
HTML Living Standard
WebSocket: onerror
Living Standard Initial definition

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onerrorChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

文档标签和贡献者

此页面的贡献者: mdnwebdocs-bot, HIKALU-Z
最后编辑者: mdnwebdocs-bot,