We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

The port property of the SharedWorker interface returns a MessagePort object used to communicate and control the shared worker.

Syntax

myWorker.port;

Value

A MessagePort object.

Example

The following code snippet shows creation of a SharedWorker object using the SharedWorker() constructor. Multiple scripts can then access the worker through a MessagePort object accessed using the SharedWorker.port property — the port is started using its start() method:

var myWorker = new SharedWorker('worker.js');
myWorker.port.start();

For a full example, see our Basic shared worker example (run shared worker.)

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'AbstractWorker.onerror' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support4 ?291010.65 — 6.1
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes ?3311.55.1 — 7.1 Yes

See also

Document Tags and Contributors

Contributors to this page: fscholz, nmve, Sebastianz, julienw, chrisdavidmills, kscarfone
Last updated by: fscholz,