onmessage event

Fires when the user sends a cross-document message or a message is sent from a Worker with IHTMLWindow6::postMessage.

 

Syntax

HTML Attribute <element onmessage = "handler(event)">
Event Property object.onmessage = handler;
attachEvent Method object.attachEvent("onmessage", handler)
addEventListener Method object.addEventListener("message", handler, useCapture)

 

Event information

Synchronous No
Bubbles No
Cancelable Yes

 

Event handler parameters

Standards information

Remarks

For info on channel messaging with Workers, see MessagePort and MessageChannel.

The HTMLWindowEvents3::onmessage event is fired when script invokes IHTMLWindow6::postMessage to send the target document a message. The IHTMLEventObj5::data property of the incoming event is set to the value passed in IHTMLWindow6::postMessage.

Security Warning: For best results, check the IHTMLEventObj5::origin attribute to ensure that messages are only accepted from domains that you expect. For more information, see Section 7.4.2 of the HTML5 (Working Draft) specification from the World Wide Web Consortium (W3C).

To invoke this event, do one of the following:

The pEvtObj parameter is required for the following interfaces: