MessagePort
Summary
Exposes the available methods on the connected ports.
Properties
No properties.
Methods
- close
- Disconnects the port, so that it is no longer active.
- postMessage
- Posts a message through the channel, from one port to the other.
- start
- Begins dispatching messages received on the port. See Notes.
Events
No events.
Notes
Two MessagePort objects are automatically created when a MessageChannel object is created, and are returned by the port1 and port2 properties. Messages are sent from one port are received by the other, and vice versa. The MessagePort object provides the start method to begin dispatching messages received on the port, and the close method to close and disconnect the port. The postMessage method sends messages through the port. In Internet Explorer 10, message ports are automatically enabled when a message event is registered with the onmessage property or addEventListener method. This makes it unnecessary to explicitly call the start method under these conditions. After posting a MessagePort object using postMessage, the MessagePort object is implicitly closed.
Related specifications
- W3C Web Messaging Specification
- W3C Candidate Recommendation
Attributions
Microsoft Developer Network: Windows Internet Explorer API reference Article