onmessage event | message event
Occurs when the postMessage method sends a message to the current window.
Note: The onmessage event is supported in Firefox from version 3 and in Internet Explorer from version 8.The event object for a message event supports the following additional properties:
- the data property contains the message,
- the origin property retrieves the scheme, hostname and port of the document that invoked the postMessage method,
- the source property refers to the window object that contains the document that invoked the postMessage method,
- the lastEventId property returns the identifier of the last message.
How to register:
This event cannot be registered in HTML.
|object.onmessage = handler;|
|object.addEventListener ("message", handler, useCapture);|
|object.attachEvent ("onmessage", handler);|
You can find the related objects in the Supported by objects section below.
The event object is accessible to all event handlers in all browsers. The properties of the event object contain additional information about the current event. To get further details about these properties and the possible event handler registration methods, please see the page for the event object.
Actions that invoke the message event:
- If a message is sent with the postMessage method.
Example HTML code 1:
This example illustrates the use of the message event.
Did you find this example helpful?
User Contributed Comments