The WorkerLocation
interface defines the absolute location of the script executed by the {{domxref("Worker")}}. Such an object is initialized for each worker and is available via the {{domxref("WorkerGlobalScope.location")}} property obtained by calling window.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 {{domxref("URLUtilsReadOnly")}} interface.
- {{domxref("URLUtilsReadOnly.href")}} {{readOnlyInline}}
- Is a {{domxref("DOMString")}} containing the whole URL of the script executed in the {{domxref("Worker")}}.
- {{domxref("URLUtilsReadOnly.protocol")}} {{readOnlyInline}}
-
Is a {{domxref("DOMString")}} containing the protocol scheme of the URL of the script executed in the {{domxref("Worker")}}, including the final
':'
. - {{domxref("URLUtilsReadOnly.host")}} {{readOnlyInline}}
-
Is a {{domxref("DOMString")}} containing the host, that is the hostname, a
':'
, and the port of the URL of the script executed in the {{domxref("Worker")}}. - {{domxref("URLUtilsReadOnly.hostname")}} {{readOnlyInline}}
- Is a {{domxref("DOMString")}} containing the domain of the URL of the script executed in the {{domxref("Worker")}}.
- {{domxref("URLUtilsReadOnly.port")}} {{readOnlyInline}}
- Is a {{domxref("DOMString")}} containing the port number of the URL of the script executed in the {{domxref("Worker")}}.
- {{domxref("URLUtilsReadOnly.pathname")}} {{readOnlyInline}}
-
Is a {{domxref("DOMString")}} containing an initial
'/'
followed by the path of the URL of the script executed in the {{domxref("Worker")}}. - {{domxref("URLUtilsReadOnly.search")}} {{readOnlyInline}}
-
Is a {{domxref("DOMString")}} containing a
'?'
followed by the parameters of the URL of the script executed in the {{domxref("Worker")}}. - {{domxref("URLUtilsReadOnly.hash")}} {{readOnlyInline}}
-
Is a {{domxref("DOMString")}} containing a
'#'
followed by the fragment identifier of the URL of the script executed in the {{domxref("Worker")}}.
Methods
The WorkerLocation
interface doesn't inherit any method, but implements methods defined in the {{domxref("URLUtilsReadOnly")}} interface.
- {{domxref("URLUtilsReadOnly.toString()")}}
- Returns a {{domxref("DOMString")}} containing the whole URL of the script executed in the {{domxref("Worker")}}. It is a synonym for {{domxref("URLUtilsReadOnly.href")}}.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('Web Workers', '#workerlocation', 'WorkerLocation')}} | {{Spec2('Web Workers')}} | Initial definition |
Browser compatibility
{{ CompatibilityTable() }}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatGeckoDesktop("1.9.1")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatGeckoMobile("1.9.1")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
See also
- Other Worker-related interfaces: {{domxref("Worker")}}, {{domxref("WorkerNavigation")}}, and {{domxref("WorkerGlobalScope")}}.
- Using web workers