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 .

规范

规范 状态 注释
HTML 实时标准
The definition of 'WorkerLocation' in that specification.
实时标准

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
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

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: