WorkerLocation
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is only available inWeb Workers.
TheWorkerLocation
interface defines the absolute location of the script executed by theWorker
. Such an object is initialized for each worker and is available via theWorkerGlobalScope.location
property obtained by callingself.location
.
This interface is only visible from inside a JavaScript script executed in the context of a Web worker.
In this article
Instance properties
WorkerLocation.href
Read onlyReturns a string containing the serialized
URL
for the worker's location.WorkerLocation.protocol
Read onlyReturns the
protocol
part of the worker's location.WorkerLocation.host
Read onlyReturns the
host
part of the worker's location.WorkerLocation.hostname
Read onlyReturns the
hostname
part of the worker's location.WorkerLocation.origin
Read onlyReturns the worker's
origin
.WorkerLocation.port
Read onlyReturns the
port
part of the worker's location.WorkerLocation.pathname
Read onlyReturns the
pathname
part of the worker's location.WorkerLocation.search
Read onlyReturns the
search
part of the worker's location.WorkerLocation.hash
Read onlyReturns the
hash
part of the worker's location.
Instance methods
WorkerLocation.toString()
Returns a string containing the serialized
URL
for the worker's location. It is a synonym forWorkerLocation.href
.
Specifications
Specification |
---|
HTML> # worker-locations> |
Browser compatibility
Loading…
See also
- Other Worker-related interfaces:
Worker
,WorkerNavigator
, andWorkerGlobalScope
- Using web workers