WorkerLocation

WorkerLocation interface defines the absolute location of the script executed by the Worker . Such an object is initialized for each worker and is available via the WorkerGlobalScope.location property obtained by calling self.location .

This interface is only visible from inside a JavaScript script executed in the context of a Web worker.

特性

WorkerLocation interface doesn't inherit any property, but implements properties defined in the URLUtilsReadOnly 接口。

URLUtilsReadOnly.href 只读
Is a stringifier that returns a DOMString containing the whole URL of the script executed in the Worker .
URLUtilsReadOnly.protocol 只读
DOMString containing the protocol scheme of the URL of the script executed in the Worker , including the final ':' .
URLUtilsReadOnly.host 只读
DOMString 包含主机,即 hostname ':' ,和 port of the URL of the script executed in the Worker .
URLUtilsReadOnly.hostname 只读
DOMString containing the domain of the URL of the script executed in the Worker .
URLUtilsReadOnly.origin 只读
返回 DOMString containing the canonical form of the origin of the specific location.
URLUtilsReadOnly.port 只读
DOMString containing the port number of the URL of the script executed in the Worker .
URLUtilsReadOnly.pathname 只读
DOMString 包含初始 '/' followed by the path of the URL of the script executed in the Worker .
URLUtilsReadOnly.search 只读
DOMString 包含 '?' followed by the parameters of the URL of the script executed in the Worker .
URLUtilsReadOnly.hash 只读
DOMString 包含 '#' followed by the fragment identifier of the URL of the script executed in the Worker .

方法

WorkerLocation interface doesn't inherit any method, but implements methods defined in the URLUtilsReadOnly 接口。

URLUtilsReadOnly.toString()
返回 DOMString containing the whole URL of the script executed in the Worker . It is a synonym for URLUtilsReadOnly.href .

规范

规范 状态 Comment
HTML Living Standard
The definition of 'WorkerLocation' in that specification.
实时标准

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
WorkerLocation Chrome 1 Edge ≤79 Firefox 3.5 IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS ? Samsung Internet Android Yes

图例

完整支持
完整支持
兼容性未知
兼容性未知

另请参阅