MessageEvent

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

當伺服器傳來資料時,客戶端會收到一個 MessageEvent,由 WebSocket 物件 onmessage 表示的監聽器接收。

屬性

屬性 形態 描述
data DOMString | Blob | ArrayBuffer 伺服器傳來的資料。

規範

Specification
HTML
# the-messageevent-interface

瀏覽器兼容

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
MessageEvent
MessageEvent() constructor
data
initMessageEvent
Deprecated
lastEventId
origin
ports
source
userActivation
Non-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.

參見