MessageEvent: source プロパティ

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.

sourceMessageEvent インターフェイスの読み取り専用プロパティで、メッセージ送信者を表す MessageEventSourceWindowProxy, MessagePort, ServiceWorker オブジェクトのいずれか)です。

メッセージ送信者を表す MessageEventSourceWindowProxy, MessagePort, ServiceWorker オブジェクトのいずれか)です。

js
myWorker.onmessage = (e) => {
  result.textContent = e.data;
  console.log("Message received from worker");
  console.log(e.source);
};

仕様書

Specification
HTML
# dom-messageevent-source-dev

ブラウザーの互換性

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
source

Legend

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

Full support
Full support

関連情報

  • ExtendableMessageEvent — このインターフェイスに似ていますが、もっと柔軟性が必要なインターフェイスで使用されます。