MessageEvent

  • Revision slug: WebSockets/WebSockets_reference/MessageEvent
  • Revision title: MessageEvent
  • Revision id: 74552
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment new page; page created, 101 words added

Revision Content

{{ draft() }}

A MessageEvent is sent to clients using WebSockets when data is received from the server. This is delivered to the listener indicated by the WebSocket object's onmessage attribute.

Attributes

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

See also

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

{{ gecko_callout_heading("6.0") }}

At this time, Gecko does not support ArrayBuffer or {{ domxref("Blob") }} for data.

Revision Source

<p>{{ draft() }}</p>
<p>A <code>MessageEvent</code> is sent to clients using WebSockets when data is received from the server. This is delivered to the listener indicated by the <code>WebSocket</code> object's <code>onmessage</code> attribute.</p>
<h2 name="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><a href="/en/DOMString" title="en/DOMString"><code>DOMString</code></a> | {{ domxref("Blob") }} | <a href="/en/JavaScript_typed_arrays/ArrayBuffer" title="en/JavaScript typed arrays/ArrayBuffer"><code>ArrayBuffer</code></a></td> <td>The data from the server.</td> </tr> </tbody>
</table>
<h2>See also</h2>
<ul> <li><a href="/en/WebSockets/WebSockets_reference/WebSocket" title="en/WebSockets/WebSockets reference/WebSocket"><code>WebSocket</code></a></li>
</ul>
<h2>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>Gecko notes</h3>
<div class="geckoVersionNote">
<p>{{ gecko_callout_heading("6.0") }}</p>
<p>At this time, Gecko does not support <code><a href="/en/JavaScript_typed_arrays/ArrayBuffer" title="en/JavaScript typed arrays/ArrayBuffer">ArrayBuffer</a></code> or {{ domxref("Blob") }} for <code>data</code>.</p>
</div>
Revert to this revision