The 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.
Properties
The WorkerLocation interface doesn't inherit any property, but implements properties defined in the URLUtilsReadOnly interface.
URLUtilsReadOnly.hrefRead only- Is a stringifier that returns a
DOMStringcontaining the whole URL of the script executed in theWorker. URLUtilsReadOnly.protocolRead only- Is a
DOMStringcontaining the protocol scheme of the URL of the script executed in theWorker, including the final':'. URLUtilsReadOnly.hostRead only- Is a
DOMStringcontaining the host, that is the hostname, a':', and the port of the URL of the script executed in theWorker. URLUtilsReadOnly.hostnameRead only- Is a
DOMStringcontaining the domain of the URL of the script executed in theWorker. URLUtilsReadOnly.originRead only- Returns a
DOMStringcontaining the canonical form of the origin of the specific location. URLUtilsReadOnly.portRead only- Is a
DOMStringcontaining the port number of the URL of the script executed in theWorker. URLUtilsReadOnly.pathnameRead only- Is a
DOMStringcontaining an initial'/'followed by the path of the URL of the script executed in theWorker. URLUtilsReadOnly.searchRead only- Is a
DOMStringcontaining a'?'followed by the parameters of the URL of the script executed in theWorker. URLUtilsReadOnly.hashRead only- Is a
DOMStringcontaining a'#'followed by the fragment identifier of the URL of the script executed in theWorker.
Methods
The WorkerLocation interface doesn't inherit any method, but implements methods defined in the URLUtilsReadOnly interface.
URLUtilsReadOnly.toString()- Returns a
DOMStringcontaining the whole URL of the script executed in theWorker. It is a synonym forURLUtilsReadOnly.href.
Specifications
| Specification | Status | Comment |
|---|---|---|
| HTML Living Standard The definition of 'WorkerLocation' in that specification. |
Living Standard |
Browser compatibility
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.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
WorkerLocation | Chrome Full support 1 | Edge Full support ≤79 | Firefox Full support 3.5 | IE ? | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
See also
- Other Worker-related interfaces:
Worker,WorkerNavigator, andWorkerGlobalScope. - Using web workers
