SharedWorker

@native @JSGlobal @JSType
class SharedWorker(scriptURL: String) extends AbstractWorker

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.

Value parameters:
options

A DOMString specifying an identifying name for the SharedWorkerGlobalScope representing the scope of the worker, which is mainly useful for debugging purposes. Or, an object containing option properties that can set when creating the object instance.

scriptURL

A DOMString representing the URL of the script the worker will execute. It must obey the same-origin policy.

Constructor:

The SharedWorker constructor creates a SharedWorker object that executes the script at the specified URL.This script must obey the same-origin policy. If the URL has an invalid syntax or if the same-origin policy is violated, a DOMException of type SECURITY_ERR is thrown.

Example:
var myWorker = new SharedWorker("aURL", name);
Companion:
object
class Object
trait Any
class Object
trait Matchable
class Any

Value members

Constructors

def this(scriptURL: String, name: String)
def this(scriptURL: String, options: WorkerOptions)

Concrete methods

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

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

Inherited methods

def addEventListener[T <: Event](`type`: String, listener: Function1[T, _], options: EventListenerOptions): Unit

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

This implementation accepts a settings object of type EventListenerOptions.

Inherited from:
EventTarget
def addEventListener[T <: Event](`type`: String, listener: Function1[T, _], useCapture: Boolean): Unit

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

Inherited from:
EventTarget
def dispatchEvent(evt: Event): Boolean

Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().

Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().

Inherited from:
EventTarget
def hasOwnProperty(v: String): Boolean
Inherited from:
Object
def isPrototypeOf(v: Object): Boolean
Inherited from:
Object
def propertyIsEnumerable(v: String): Boolean
Inherited from:
Object
def removeEventListener[T <: Event](`type`: String, listener: Function1[T, _], options: EventListenerOptions): Unit

Removes the event listener previously registered with EventTarget.addEventListener.

Removes the event listener previously registered with EventTarget.addEventListener.

This implementation accepts a settings object of type EventListenerOptions.

Inherited from:
EventTarget
def removeEventListener[T <: Event](`type`: String, listener: Function1[T, _], useCapture: Boolean): Unit

Removes the event listener previously registered with EventTarget.addEventListener.

Removes the event listener previously registered with EventTarget.addEventListener.

Inherited from:
EventTarget
def toLocaleString(): String
Inherited from:
Object
def valueOf(): Any
Inherited from:
Object

Inherited fields

var onerror: Function1[ErrorEvent, _]

The AbstractWorker.onerror property represents an EventHandler, that is a function to be called when the error event occurs and bubbles through the Worker.

The AbstractWorker.onerror property represents an EventHandler, that is a function to be called when the error event occurs and bubbles through the Worker.

Inherited from:
AbstractWorker