Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 465579 of WorkerLocation

  • Revision slug: Web/API/WorkerLocation
  • Revision title: WorkerLocation
  • Revision id: 465579
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment
Tags: 

Revision Content

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("WorkerNavigator")}}, and {{domxref("WorkerGlobalScope")}}.
  • Using web workers

Revision Source

<p>The <strong><code>WorkerLocation</code></strong> 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 <code>window.self.location</code>.</p>
<p>This interface is only visible from inside a JavaScript script executed in the context of a Web worker.</p>
<h2 id="Properties">Properties</h2>
<p><em>The <code>WorkerLocation</code> interface doesn't inherit any property, but implements properties defined in the {{domxref("URLUtilsReadOnly")}} interface.</em></p>
<dl>
  <dt>
    {{domxref("URLUtilsReadOnly.href")}} {{readOnlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing the whole URL of the script executed in the {{domxref("Worker")}}.</dd>
  <dt>
    {{domxref("URLUtilsReadOnly.protocol")}} {{readOnlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing the protocol scheme of the URL of the script executed in the {{domxref("Worker")}}, including the final <code>':'</code>.</dd>
  <dt>
    {{domxref("URLUtilsReadOnly.host")}} {{readOnlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing the host, that is the <em>hostname</em>, a <code>':'</code>, and the <em>port</em> of the URL of the script executed in the {{domxref("Worker")}}.</dd>
  <dt>
    {{domxref("URLUtilsReadOnly.hostname")}} {{readOnlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing the domain of the URL of the script executed in the {{domxref("Worker")}}.</dd>
  <dt>
    {{domxref("URLUtilsReadOnly.port")}} {{readOnlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing the port number of the URL of the script executed in the {{domxref("Worker")}}.</dd>
  <dt>
    {{domxref("URLUtilsReadOnly.pathname")}} {{readOnlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing an initial <code>'/'</code> followed by the path of the URL of the script executed in the {{domxref("Worker")}}.</dd>
  <dt>
    {{domxref("URLUtilsReadOnly.search")}} {{readOnlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing a <code>'?'</code> followed by the parameters of the URL of the script executed in the {{domxref("Worker")}}.</dd>
  <dt>
    {{domxref("URLUtilsReadOnly.hash")}} {{readOnlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing a <code>'#'</code> followed by the fragment identifier of the URL of the script executed in the {{domxref("Worker")}}.</dd>
</dl>
<h2 id="Methods">Methods</h2>
<p><em>The <code>WorkerLocation</code> interface doesn't inherit any method, but implements methods defined in the {{domxref("URLUtilsReadOnly")}} interface.</em></p>
<dl>
  <dt>
    {{domxref("URLUtilsReadOnly.toString()")}}</dt>
  <dd>
    Returns a {{domxref("DOMString")}} containing the whole URL of the script executed in the {{domxref("Worker")}}. It is a synonym for {{domxref("URLUtilsReadOnly.href")}}.</dd>
</dl>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{SpecName('Web Workers', '#workerlocation', 'WorkerLocation')}}</td>
      <td>{{Spec2('Web Workers')}}</td>
      <td>Initial definition</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatGeckoDesktop("1.9.1")}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Chrome for Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatGeckoMobile("1.9.1")}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>Other Worker-related interfaces: {{domxref("Worker")}}, {{domxref("WorkerNavigator")}}, and {{domxref("WorkerGlobalScope")}}.</li>
  <li><a href="/en-US/docs/Web/Guide/Performance/Using_web_workers" title="/en-US/docs/Web/Guide/Performance/Using_web_workers">Using web workers</a></li>
</ul>
<dl>
  <br />
</dl>
Revert to this revision