The BroadcastChannel.onmessage
event handler is a property that specifies the function to execute when a message
event, of type MessageEvent
, is received by this BroadcastChannel
. Such an event is sent by the browser with a message broadcasted to the channel.
channel.onmessage = function;
function
is the name of a user-defined function, without the ()
suffix or any parameters, or an anonymous function declaration, such as function(event) {...}
. An event handler always has one single parameter, containing the event, here of type MessageEvent
.bc.onmessage = function(ev) { console.log('message event received!'); };
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'BroadcastChannel.onmessage' in that specification. | Living Standard | Initial definition. |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 54.0 | 38 (38) | No support | 41 | No support |
Available in workers | 54.0 | 38 (38) | No support | 41 | No support |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | No support | No support | 38.0 (38) | No support | 41 | No support | 54.0 |
Available in workers | No support | No support | 38.0 (38) | No support | 41 | No support | 54.0 |
ServiceWorker
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/onmessage