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.

port1

Summary

Returns the first MessagePort object of the MessageChannel.

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

Syntax

Note: This property is read-only.

var result = element.port1;

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.port1.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