Location.reload()

  • Revision slug: Web/API/Location.reload
  • Revision title: Location.reload()
  • Revision id: 463705
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ APIRef("Location") }}

The Location.reload()method Reloads the resource from the current URL. Its optional unique parameter is a {{domxref("Boolean")}}, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.

If the assignment can't happen because of a security violation, a {{domxref("DOMException")}} of the SECURITY_ERROR type is thrown. This happens if the origin of the script calling the method is different from the origin of the page originally described by the {{domxref("Location")}} object, mostly when the script is hosted on a different domain.

Syntax

object.reload(forcedReload);

Parameters

forcedReload {{optional_inline}}
Is a {{domxref("Boolean")}} flag, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.

Examples

// Reload the current page, without using the cache
document.location.replace(true);

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', "history.html#dom-location-reload", "Location.reload()")}} {{Spec2('HTML WHATWG')}} No change from {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "browsers.html#dom-location-reload", "Location.reload()")}} {{Spec2('HTML5 W3C')}} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

See also

  • The {{domxref("Location")}} interface it belongs to.
  • Similar methods: {{domxref("Location.assign()")}} and {{domxref("Location.replace()")}}.

Revision Source

<p>{{ APIRef("Location") }}</p>
<p>The <code><strong>Location</strong></code><strong><code>.reload()</code></strong>method Reloads the resource from the current URL. Its optional unique parameter is a {{domxref("Boolean")}}, which, when it is <code>true</code>, causes the page to always be reloaded from the server. If it is <code>false</code> or not specified, the browser may reload the page from its cache.</p>
<p>If the assignment can't happen because of a security violation, a {{domxref("DOMException")}} of the <code>SECURITY_ERROR</code> type is thrown. This happens if the origin of the script calling the method is different from the origin of the page originally described by the {{domxref("Location")}} object, mostly when the script is hosted on a different domain.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">
<em>object</em>.reload(<em>forcedReload</em>);
</pre>
<h3>Parameters</h3>
<dl>
  <dt>
    <em>forcedReload</em> {{optional_inline}}</dt>
  <dd>
    Is a {{domxref("Boolean")}} flag, which, when it is <code>true</code>, causes the page to always be reloaded from the server. If it is <code>false</code> or not specified, the browser may reload the page from its cache.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre class="brush: js">
// Reload the current page, without using the cache
document.location.replace(true);</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
    <tr>
      <td>{{SpecName('HTML WHATWG', "history.html#dom-location-reload", "Location.reload()")}}</td>
      <td>{{Spec2('HTML WHATWG')}}</td>
      <td>No change from {{SpecName("HTML5 W3C")}}.</td>
    </tr>
    <tr>
      <td>{{SpecName('HTML5 W3C', "browsers.html#dom-location-reload", "Location.reload()")}}</td>
      <td>{{Spec2('HTML5 W3C')}}</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>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</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>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>The {{domxref("Location")}} interface it belongs to.</li>
  <li>Similar methods: {{domxref("Location.assign()")}} and {{domxref("Location.replace()")}}.</li>
</ul>
Revert to this revision