Create a new EventSource object, and specify the URL of the page sending the
updates.
When (and if) a connection is established, output some text in a
<h1> element:
The onopen event occurs when a connection with an event source is opened.
Related events:
For more information about Server-Sent Events, read our HTML5 Server-Sent Events Tutorial.
The numbers in the table specify the first browser version that fully supports the event.
Event | |||||
---|---|---|---|---|---|
onopen | 9.0 | Not supported | 6.0 | 5.0 | 11.0 |
Using the addEventListener() method:
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |