This page is Ready to Use

Notice: The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.



Creates a connection (two “entangled” ports) to enable independent pieces of code (running in different browsing contexts) to communicate directly.


Returns the first MessagePort object of the MessageChannel.
Returns the second MessagePort object.


No methods.


No events.


var msgChannel = new MessageChannel();


When you create a new MessageChannel object, it has two connected MessagePort objects (port1 and port2). One of the ports is sent to another window or frame, and messages can be sent and received without the repeated origin checking that is needed when using window.postMessage. Validation of the origin of a port and messages need only be done when a port is sent to windows other than the one that created them. MessagePort simplifies the messaging process by sending and receiving messages through two (and only those two) connected ports.

Messages are posted between the ports using postMessage. As the ports will only accept messages between the connected ports, no further validation is required once the connection is established. MessageChannel enables asynchronous communication between IFrameElements, cross-domain windows, or same page communications.

Related specifications

W3C Web Messaging Specification
W3C Candidate Recommendation