MessageEvent Class

https://html.spec.whatwg.org/multipage/comms.html#messageevent

public sealed class MessageEvent : Event
Inheritance
Event MessageEvent

Constructors

NameDescription
MessageEvent(string, MessageEventInit?)Creates a message event with the given type and initialization dictionary.

MessageEvent(string, MessageEventInit?)

HtmlEvents.cs

Creates a message event with the given type and initialization dictionary.

public MessageEvent(string type, MessageEventInit? eventInitDict = null)

Properties

NameDescription
DataGets the data of the message.
LastEventIdGets the last event ID of the event source that sent the message.
OriginGets the origin of the message sender.
PortsGets the message ports sent with the message (https://html.spec.whatwg.org/multipage/comms.html#dom-messageevent-ports).
SourceGets the object that sent the message, such as a window or a message port.

Gets the data of the message.

public object? Data { get; }

LastEventId

HtmlEvents.cs

Gets the last event ID of the event source that sent the message.

public string LastEventId { get; }

Gets the origin of the message sender.

public string Origin { get; }

Gets the message ports sent with the message (https://html.spec.whatwg.org/multipage/comms.html#dom-messageevent-ports).

public IReadOnlyList<MessagePort> Ports { get; }

Gets the object that sent the message, such as a window or a message port.

public EventTarget? Source { get; }

Methods

NameDescription
InitMessageEvent(string, bool, bool, object?, string, string, EventTarget?, IReadOnlyList<MessagePort>?)https://html.spec.whatwg.org/multipage/comms.html#dom-messageevent-initmessageevent

InitMessageEvent(string, bool, bool, object?, string, string, EventTarget?, IReadOnlyList<MessagePort>?)

HtmlEvents.cs

https://html.spec.whatwg.org/multipage/comms.html#dom-messageevent-initmessageevent

public void InitMessageEvent(string type, bool bubbles = false, bool cancelable = false, object? data = null, string origin = "", string lastEventId = "", EventTarget? source = null, IReadOnlyList<MessagePort>? ports = null)