MessageEvent extension type
The MessageEvent
interface represents a message received by a target
object.
This is used to represent messages in:
- Server-sent events
(see
EventSource.message_event
). - Web sockets
(see the
onmessage
property of the WebSocket interface). - Cross-document messaging (see Window.postMessage and
Window.message_event
). - Channel messaging
(see MessagePort.postMessage and
MessagePort.message_event
). - Cross-worker/document messaging (see the above two entries, but also
Worker.postMessage,
Worker.message_event
,ServiceWorkerGlobalScope.message_event
, etc.) - Broadcast channels
(see BroadcastChannel.postMessage) and
BroadcastChannel.message_event
). - WebRTC data channels (see
RTCDataChannel.message_event
).
The action triggered by this event is defined in a function set as the event
handler for the relevant message
event (e.g. using an onmessage
handler
as listed above).
Constructors
- MessageEvent(String type, [MessageEventInit eventInitDict])
-
factory
Properties
- bubbles → bool
-
no setterinherited
- cancelable → bool
-
no setterinherited
- cancelBubble ↔ bool
-
getter/setter pairinherited
- composed → bool
-
no setterinherited
- currentTarget → EventTarget?
-
no setterinherited
- data → JSAny?
-
no setter
- defaultPrevented → bool
-
no setterinherited
- eventPhase → int
-
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isTrusted → bool
-
no setterinherited
- lastEventId → String
-
no setter
- origin → String
-
no setter
-
ports
→ JSArray<
MessagePort> -
no setter
- returnValue ↔ bool
-
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → MessageEventSource?
-
no setter
- srcElement → EventTarget?
-
no setterinherited
- target → EventTarget?
-
no setterinherited
- timeStamp → DOMHighResTimeStamp
-
no setterinherited
- type → String
-
no setterinherited
Methods
-
composedPath(
) → JSArray< EventTarget> -
The
composedPath()
method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked. This does not include nodes in shadow trees if the shadow root was created with its ShadowRoot.mode closed.inherited -
initEvent(
String type, [bool bubbles, bool cancelable]) → void -
The
Event.initEvent()
method is used to initialize the value of anevent
created using Document.createEvent.inherited -
initMessageEvent(
String type, [bool bubbles, bool cancelable, JSAny? data, String origin, String lastEventId, MessageEventSource? source, JSArray< MessagePort> ports]) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
preventDefault(
) → void -
The
preventDefault()
method of the Event interface tells the that if the event does not get explicitly handled, its default action should not be taken as it normally would be.inherited -
stopImmediatePropagation(
) → void -
The
stopImmediatePropagation()
method of the Event interface prevents other listeners of the same event from being called.inherited -
stopPropagation(
) → void -
The
stopPropagation()
method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on links are still processed. If you want to stop those behaviors, see the Event.preventDefault method. It also does not prevent propagation to other event-handlers of the current element. If you want to stop those, see Event.stopImmediatePropagation.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited