WorkerLocation
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
-
WorkerLocation.hrefRead only -
Returns a
USVStringcontaining the serializedURLfor the worker’s location. -
WorkerLocation.protocolRead only -
Returns the
protocolpart of the worker’s location. -
WorkerLocation.hostRead only -
Returns the
hostpart of the worker’s location. -
WorkerLocation.hostnameRead only -
Returns the
hostnamepart of the worker’s location. -
WorkerLocation.originRead only -
Returns the worker’s
origin. -
WorkerLocation.portRead only -
Returns the
portpart of the worker’s location. -
WorkerLocation.pathnameRead only -
Returns the
pathnamepart of the worker’s location. -
WorkerLocation.searchRead only -
Returns the
searchpart of the worker’s location. -
WorkerLocation.hashRead only -
Returns the
hashpart of the worker’s location.
Methods
WorkerLocation.toString()-
Returns a
USVStringcontaining the serializedURLfor the worker’s location. It is a synonym forWorkerLocation.href.
Specifications
| Specification |
|---|
| HTML Standard (HTML) # worker-locations |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
WorkerLocation |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
hash |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
host |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
hostname |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
href |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
origin |
38 |
14 |
29 |
No |
25 |
10 |
38 |
38 |
29 |
25 |
10 |
3.0 |
pathname |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
port |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
protocol |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
search |
3 |
12 |
3.5 |
10 |
≤12.1 |
4 |
≤37 |
18 |
4 |
≤12.1 |
5 |
1.0 |
toString |
3 |
12 |
3.5 |
10 |
≤15 |
4 |
≤37 |
18 |
4 |
≤14 |
5 |
1.0 |
See also
- Other Worker-related interfaces:
Worker,WorkerNavigator, andWorkerGlobalScope. - Using web workers
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation