The messageerror event is fired on a BroadcastChannel object when a message arrives on the channel that can't be deserialized.
| Bubbles | No |
|---|---|
| Cancelable | No |
| Interface | MessageEvent |
| Event handler property | onmessageerror |
Examples
This code uses addEventListener to listen for messages and errors:
const channel = new BroadcastChannel('example-channel');
channel.addEventListener('message', (event) => {
received.textContent = event.data;
});
channel.addEventListener('messageerror', (event) => {
console.error(event);
});
The same, but using the onmessage and onmessageerror event handler properties:
const channel = new BroadcastChannel('example-channel');
channel.onmessage = (event) => {
received.textContent = event.data;
};
channel.onmessageerror = (event) => {
console.log(event);
};
Specifications
| Specification | Status |
|---|---|
| HTML Living Standard | Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
messageerror event | Chrome Full support 60 | Edge Full support ≤79 | Firefox Full support 57 | IE No support No | Opera Full support 47 | Safari No support No | WebView Android Full support 60 | Chrome Android Full support 60 | Firefox Android ? | Opera Android Full support 47 | Safari iOS No support No | Samsung Internet Android Full support 8.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
See also
- Related events:
message.
