--- title: onmessage slug: Web/API/WindowEventHandlers/onmessage translation_of: Web/API/WindowEventHandlers/onmessage ---
{{APIRef("HTML DOM")}}{{ SeeCompatTable() }}
{{domxref("WindowEventHandlers")}}的onmessage
属性是当对象接收到{{event("message")}} 事件时被调用的{{domxref("EventHandler")}} .
window.addEventListener('message', function(event) { ... }) window.onmessage = function(event) { ... }
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG','#handler-window-onmessage','onmessage')}} | {{Spec2('HTML WHATWG')}} | Initial definition. |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(60)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOpera(47)}} | {{CompatUnknown}} |
Feature | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | {{CompatChrome(60)}} | {{CompatChrome(60)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOperaMobile(47)}} | {{CompatUnknown}} |