这篇翻译不完整。请帮忙从英语翻译这篇文章

WebSocket.onmessage 属性返回一事件监听器,当从服务器收到一条消息时,该监听器将被调用。该监听器接受一命名为 message 的 MessageEvent

语法

aWebSocket.onmessage = function(event) {
  console.debug("WebSocket message received:", event);
};

一个 EventListener.

规范

规范 状态 注释
HTML Living Standard
WebSocket: onmessage
Living Standard 初始定义

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onmessageChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

文档标签和贡献者

此页面的贡献者: mdnwebdocs-bot, Ray-Eldath
最后编辑者: mdnwebdocs-bot,