此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
WebSocket.protocol 是个只读属性,用于返回服务器端选中的子协议的名字;这是一个在创建 WebSocket 对象时,在参数 protocols 中指定的字符串,当没有已建立的链接时为空串。
var protocol = aWebSocket.protocol;
| Specification |
|---|
| WebSockets> # ref-for-dom-websocket-protocol①> |