This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

onerror

Summary

An event listener to be called when an error occurs. Receives an event named "error".

Property of apis/websocket/WebSocketapis/websocket/WebSocket

Syntax

Note: This property is read-only.

var result = element.onerror;

Return Value

Returns an object of type

EventHandler

Examples

socket.onerror = function(event) {
  // handle error event
};

An equivalent “onerror” event handler that uses the addEventListener() method.

socket.addEventListener("error", function(event) {
  // handle error event
});

Related specifications

W3C WebSocket Specification
W3C Candidate Recommendation

Attributions