The onopen property of the EventSource interface is an EventHandler called when an open event is received, that is when the connection was just opened.

Syntax

eventSource.onopen = function

Examples

evtSource.onopen = function() {
  console.log("Connection to server opened.");
};

Note: You can find a full example on GitHub — see Simple SSE demo using PHP.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'onopen' in that specification.
Living Standard Initial definition

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 6Edge No support NoFirefox Full support 6IE No support NoOpera Full support YesSafari Full support 5WebView Android Full support YesChrome Android Full support 18Edge Mobile No support NoFirefox Android Full support 45Opera Android Full support 12Safari iOS Full support 5Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Contributors to this page: fscholz, Sheppy, chrisdavidmills
Last updated by: fscholz,