diff options
Diffstat (limited to 'files/zh-cn/web/api/location/reload/index.html')
-rw-r--r-- | files/zh-cn/web/api/location/reload/index.html | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/location/reload/index.html b/files/zh-cn/web/api/location/reload/index.html new file mode 100644 index 0000000000..482a779a89 --- /dev/null +++ b/files/zh-cn/web/api/location/reload/index.html @@ -0,0 +1,109 @@ +--- +title: Location.reload() +slug: Web/API/Location/reload +translation_of: Web/API/Location/reload +--- +<p>{{ APIRef("HTML DOM") }}</p> + +<p><code><strong>Location.reload()</strong></code> 方法用来刷新当前页面。该方法只有一个参数,当值为 <code>true</code> 时,将强制浏览器从服务器加载页面资源,当值为 <code>false</code> 或者未传参时,浏览器则可能从缓存中读取页面。</p> + +<p>该方法在跨域调用(执行该方法的脚本文件的域和 {{domxref("Location")}} 对象所在页面的跨不同)时,将会抛出 {{domxref("DOMException")}} 异常。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><em>object</em>.reload(<em>forcedReload</em>); +</pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><em>forcedReload </em>{{optional_inline}}</dt> + <dd>该参数要求为 {{domxref("Boolean","布尔")}} 类型,当取值为 <code>true</code> 时,将强制浏览器从服务器重新获取当前页面资源,而不是从浏览器的缓存中读取,如果取值为 <code>false</code> 或不传该参数时,浏览器则可能会从缓存中读取当前页面。</dd> +</dl> + +<h2 id="示例">示例</h2> + +<pre class="brush: js">// 无缓存刷新页面(但页面引用的资源还是可能使用缓存, +// 大多数浏览器可以通过设置在打开开发者工具时禁用缓存实现无缓存需求) +window.location.reload(true);</pre> + +<h2 id="规范">规范</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="浏览器兼容性">浏览器兼容性</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="相关链接">相关链接</h2> + +<ul> + <li>{{domxref("Location")}} 接口。</li> + <li>类似功能的方法:{{domxref("Location.assign()")}} 和 {{domxref("Location.replace()")}}.</li> +</ul> |