This page is Almost Ready

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

postMessage

Summary

Posts a message to the worker with which the object is associated.

Method of apis/workers/Workerapis/workers/Worker

Syntax

 object.postMessage(message, transfer);

Parameters

message

Data-type
any

This argument can be structured data, e.g.: worker.postMessage({opcode: 'activate', device: 1938, parameters: [23, 102]});

transfer

Data-type
any

(Optional)

Return Value

No return value

Notes

A message can be a JavaScript primitive, object, or array, but not a function.

Related specifications

W3C Web Workers Specification
W3C Editor’s Draft

Attributions