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"
语法
WebSocket.onerror = function(event) { console.error("WebSocket error observed:", event); };
值
An EventListener
.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard WebSocket: onerror |
Living Standard | Initial definition |
浏览器兼容性
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.