Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 968247 of ServiceWorkerMessageEvent

  • Revision slug: Web/API/ServiceWorkerMessageEvent
  • Revision title: ServiceWorkerMessageEvent
  • Revision id: 968247
  • Created:
  • Creator: narohcp
  • Is current revision? No
  • Comment

Revision Content

{{APIRef("Service Workers API")}}{{SeeCompatTable}}
 

The ServiceWorkerMessageEvent interface of the {{domxref("ServiceWorker_API", "ServiceWorker API")}} contains information about an event sent to a navigator.serviceWorker target. This interface inherits from the {{domxref("Event")}} interface.

{{InheritanceDiagram('','','', 'ServiceWorkerMessageEvent')}}

Constructor

{{domxref("ServiceWorkerMessageEvent.ServiceWorkerMessageEvent()")}}
Creates a new ServiceWorkerMessageEvent object.

Properties

Inherits properties from its parent, {{domxref("Event")}}.

{{domxref("ServiceWorkerMessageEvent.data")}} {{readonlyinline}}
Returns the event's data. It can be any data type.
{{domxref("ServiceWorkerMessageEvent.origin")}} {{readonlyinline}}
Returns the origin of the service worker's environment settings object.
{{domxref("ServiceWorkerMessageEvent.lastEventId")}} {{readonlyinline}}
Represents, in server-sent events, the last event ID of the event source.
{{domxref("ServiceWorkerMessageEvent.source")}} {{readonlyinline}}
Returns a reference to the service worker that sent the message.
{{domxref("ServiceWorkerMessageEvent.ports")}} {{readonlyinline}}
Returns an array of {{domxref("MessagePort")}} objects.

Methods

Inherits methods from its parent, {{domxref("Event")}}.

Examples

// TBD

Specifications

Specification Status Comment
{{SpecName('Service Workers', '#serviceworkermessage-event-section', 'ServiceWorkerMessageEvent')}} {{Spec2('Service Workers')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome(45.0)}} {{CompatGeckoDesktop("44.0")}} {{CompatNo}} 24 {{CompatNo}}
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatNo}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatNo}} {{CompatUnknown}} {{CompatNo}} {{CompatChrome(45.0)}}

See also

Revision Source

<div>{{APIRef("Service Workers API")}}{{SeeCompatTable}}</div>

<div>&nbsp;</div>

<p>The ServiceWorkerMessageEvent interface of the {{domxref("ServiceWorker_API", "ServiceWorker API")}} contains information about an event sent to a <code>navigator.serviceWorker</code>&nbsp;target.&nbsp;This interface inherits from the {{domxref("Event")}} interface.</p>

<p>{{InheritanceDiagram('','','', 'ServiceWorkerMessageEvent')}}</p>

<h2 id="Constructor">Constructor</h2>

<dl>
 <dt>{{domxref("ServiceWorkerMessageEvent.ServiceWorkerMessageEvent()")}}</dt>
 <dd>Creates a new <code>ServiceWorkerMessageEvent</code> object.</dd>
</dl>

<h2 id="Properties">Properties</h2>

<p><em>Inherits properties from its parent, </em><em>{{domxref("Event")}}</em>.</p>

<dl>
 <dt>{{domxref("ServiceWorkerMessageEvent.data")}} {{readonlyinline}}</dt>
 <dd>Returns the event's data. It can be any data type.</dd>
 <dt>{{domxref("ServiceWorkerMessageEvent.origin")}} {{readonlyinline}}</dt>
 <dd>Returns the origin of the service worker's environment settings object.</dd>
 <dt>{{domxref("ServiceWorkerMessageEvent.lastEventId")}} {{readonlyinline}}</dt>
 <dd>Represents, in <a href="en-US/docs/Server-sent_events/Using_server-sent_events">server-sent events</a>, the last event ID of the event source.</dd>
 <dt>{{domxref("ServiceWorkerMessageEvent.source")}} {{readonlyinline}}</dt>
 <dd>Returns a reference to the service worker that sent the message.</dd>
 <dt>{{domxref("ServiceWorkerMessageEvent.ports")}} {{readonlyinline}}</dt>
 <dd>Returns an array of {{domxref("MessagePort")}} objects.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<p><em>Inherits methods from its parent, </em><em>{{domxref("Event")}}</em>.</p>

<h2 id="Examples">Examples</h2>

<p>// TBD</p>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Service Workers', '#serviceworkermessage-event-section', 'ServiceWorkerMessageEvent')}}</td>
   <td>{{Spec2('Service Workers')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome(45.0)}}</td>
   <td>{{CompatGeckoDesktop("44.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>24</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatChrome(45.0)}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API/Using_Service_Workers">Using Service Workers</a></li>
 <li><a class="external external-icon" href="https://github.com/mdn/sw-test">Service workers basic code example</a></li>
 <li><a class="external external-icon" href="https://jakearchibald.github.io/isserviceworkerready/">Is ServiceWorker ready?</a></li>
 <li><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers">Using web workers</a></li>
</ul>
Revert to this revision