# class SharedWorker

#### package js.html

#### extends EventTarget

Available on HTML5

The `SharedWorker` interface represents a specific kind of worker that can be accessed from several browsing contexts, such as several windows, iframes or even workers. They implement an interface different than dedicated workers and have a different global scope, `SharedWorkerGlobalScope`.

Documentation SharedWorker by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker

### Constructor

###

`new (scriptURL:String, ?name:String)`

Throws:

`null` | DOMError

### Variables

###

`onerror:Function`

###

`read onlyport:MessagePort`

Returns a `MessagePort` object used to communicate and control the shared worker.

### Inherited Variables

### Inherited Methods

#### Defined by EventTarget

###

`addEventListener (type:String, listener:Function, capture:Bool = false):Void`

`addEventListener (type:String, listener:EventListener, capture:Bool = false, ?wantsUntrusted:Bool):Void`

Throws:

`null` | DOMError

###

`dispatchEvent (event:Event):Bool`

Throws:

`null` | DOMError

###

`removeEventListener (type:String, listener:Function, capture:Bool = false):Void`

`removeEventListener (type:String, listener:EventListener, capture:Bool = false):Void`

Throws:

`null` | DOMError