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 898853 of MessageEvent

  • Revision slug: Web/API/MessageEvent
  • Revision title: MessageEvent
  • Revision id: 898853
  • Created:
  • Creator: Sebastianz
  • Is current revision? No
  • Comment Added 'NeedsBrowserCompatibility' and 'NeedsSpecTable' tags

Revision Content

{{APIRef("HTML DOM")}}

A MessageEvent is the interface representing a message received by a target, being a {{domxref("WebSocket")}} or a WebRTC {{domxref("RTCDataChannel")}}

The action triggered by this event is set via an event handler set on {{domxref("WebSocket.onmessage")}} or {{domxref("RTCDataChannel.onmessage")}}.

Attributes

Attribute Type Description
data {{domxref("DOMString")}} | {{domxref("Blob")}} | ArrayBuffer The data from the server.

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatUnknown}} {{CompatGeckoDesktop("2.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

Gecko notes

Note: As of {{Gecko("11.0")}}, Gecko supports ArrayBuffer for data, but not {{domxref("Blob")}}.

See also

Revision Source

<div>{{APIRef("HTML DOM")}}</div>

<p>A <code><strong>MessageEvent</strong></code> is the interface representing a message received by a target, being a {{domxref("WebSocket")}} or a WebRTC {{domxref("RTCDataChannel")}}</p>

<p>The action triggered by this event is set via an event handler set on {{domxref("WebSocket.onmessage")}} or {{domxref("RTCDataChannel.onmessage")}}.</p>

<h2 id="Attributes">Attributes</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <td class="header">Attribute</td>
   <td class="header">Type</td>
   <td class="header">Description</td>
  </tr>
  <tr>
   <td><code>data</code></td>
   <td>{{domxref("DOMString")}} | {{domxref("Blob")}} | <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer"><code>ArrayBuffer</code></a></td>
   <td>The data from the server.</td>
  </tr>
 </tbody>
</table>

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

<p>{{CompatibilityTable}}</p>

<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</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("2.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h3 id="Gecko_notes">Gecko notes</h3>

<div class="note">
<p><strong>Note:</strong> As of {{Gecko("11.0")}}, Gecko supports <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a></code> for data, but not {{domxref("Blob")}}.</p>
</div>

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

<ul>
 <li><a href="/en-US/docs/Web/API/WebSocket"><code>WebSocket</code></a></li>
 <li><code>WebRTC</code></li>
</ul>
Revert to this revision