The BroadcastChannel interface represents a named channel that any browsing context of a given origin can subscribe to. It allows communication between different documents (in different windows, tabs, frames or iframes) of the same origin. Messages are broadcasted via a message event fired at all BroadcastChannel objects listening to the channel.

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

See also:

Constructor

new(channel:String)

Throws:

null

DOMError

Variables

read onlyname:String

Returns a DOMString, the name of the channel.

onmessage:Function

An EventHandler property that specifies the function to execute when a message event is fired on this object.

onmessageerror:Function

An EventHandler called when a MessageEvent of type MessageError is fired—that is, when it receives a message that cannot be deserialized.

Methods

close():Void

Closes the channel object, indicating it won't get any new messages, and allowing it to be, eventually, garbage collected.

postMessage(message:Dynamic):Void

Sends the message, of any type of object, to each BroadcastChannel object listening to the same channel.

Throws:

null

DOMError

Inherited Variables

Inherited Methods

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError