postMessage

Jump to: navigation, search

postMessage

This page has been flagged with the following issues:

High-level issues:


W3C Candidate Recommendation

Summary

Posts a message through the channel, from one port to the other.

Method of apis/web-messaging/MessagePort

Syntax

 element.postMessage(message, transfer);

Parameters

message

Data-type: any


JavaScript primitive, such as a string, PixelArray, ImageData, Blob, File, or ArrayBuffer.


transfer

Data-type: any Optional

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.

Return Value

No return value

Needs Examples: This section should include examples.

Notes

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.


Related specifications

Specification Status Related Changes
W3C Web Messaging Specification W3C Candidate Recommendation

Compatibility

Desktop

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic Support 23.0
16.0
8.0 (partial)
12.1
5.1

Mobile

Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic Support 2.1
7.0
?
?
?
?
5.0
3.2

Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: Windows Internet Explorer API reference Article