onopen used when connection to server is opened - HTML

Q.  Which event will be used when a connection to the server is opened.
- Published on 19 Oct 15

a. onopen
b. onmessage
c. onerror
d. None of the above

ANSWER: onopen
 

    Discussion

  • Nirja Shah   -Posted on 05 Nov 15
    onopen
    - This event occurs when a connection with an event source is opened.

    onmessage
    - This event occurs when a message is received through an event source.

    - The event object for the onmessage event supports the following properties:
    1. data - Contains the actual message
    2. origin - The URL of the document that invoked the event
    3. lastEventId - the identifier of the last message seen in the event stream

    onerror
    - This event occurs when an error occurs with the event source.
    - Whenever a connection is disrupted an error occurs.
    - If this happens, the EventSource object will automatically attempt to reconnect to the server.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)