Posts a message through the channel, from one port to the other.
Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side. Throws a DataCloneError if transfer array contains duplicate objects or the source or target ports, or if message could not be cloned.
No return value
This example creates a new message channel and uses one of the ports to send a message, which will be received by the other port.
var msgChannel = new MessageChannel(); msgChannel.port1.postMessage('Hello world');
When you create a new MessageChannel object, it has two connected MessagePort objects that can only send and receive messages between them. If the ports parameter is supplied but contains errors, an InvalidStateError exception is thrown. Sending a message containing an un-supported object (such as a function), a DataCloneError exception is thrown.
- W3C Web Messaging Specification
- W3C Candidate Recommendation
Microsoft Developer Network: Windows Internet Explorer API reference Article