onopen
Summary
An event listener to be called when the WebSocket connection’s readyState changes to OPEN. Receives an event named "open".
Property of apis/websocket/WebSocketapis/websocket/WebSocket
Syntax
Note: This property is read-only.
var result = element.onopen;
Return Value
Returns an object of type
EventHandler
Examples
socket.onopen = function(event) {
// handle open event
};
Event handlers can also be created using the addEventListener() method.
socket.addEventListener("open", function(event) {
// handle open event
});
Related specifications
- W3C WebSocket Specification
- W3C Candidate Recommendation
Attributions
Microsoft Developer Network: Windows Internet Explorer API reference Article