This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

port2

Summary

Returns the second MessagePort object.

Property of apis/web-messaging/MessageChannelapis/web-messaging/MessageChannel

Syntax

Note: This property is read-only.

var result = element.port2;

Return Value

Returns an object of type

MessagePort

Examples

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.port2.postMessage('Hello world');

Notes

Communication channels in this mechanism are implemented as two-way pipes, with a port at each end. Messages sent in one port are delivered at the other port, and vice versa. Messages are asynchronous, and delivered as DOM events.

Related specifications

W3C Web Messaging Specification
W3C Candidate Recommendation

Attributions