--- title: WebSocket.url slug: Web/API/WebSocket/url tags: - API - Property - Refrence - Web API - WebSocket translation_of: Web/API/WebSocket/url ---

{{APIRef("Web Sockets API")}}

The WebSocket.url read-only property returns the absolute URL of the {{domxref("WebSocket")}} as resolved by the constructor.

WebSocket.url是一个只读属性,返回值为当构造函数创建{{domxref("WebSocket")}}实例对象时URL的绝对路径。

语法

var url = aWebSocket.url;

 

返回值

A DOMString.

规范

Specification Status Comment
{{SpecName('HTML WHATWG', '#dom-websocket-url', 'WebSocket: url')}} {{Spec2('HTML WHATWG')}} Initial definition

浏览器兼容性

{{Compat("api.WebSocket.url")}}