aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/location
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/location
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/location')
-rw-r--r--files/zh-cn/web/api/location/assign/index.html71
-rw-r--r--files/zh-cn/web/api/location/hash/index.html47
-rw-r--r--files/zh-cn/web/api/location/host/index.html52
-rw-r--r--files/zh-cn/web/api/location/hostname/index.html43
-rw-r--r--files/zh-cn/web/api/location/href/index.html44
-rw-r--r--files/zh-cn/web/api/location/index.html219
-rw-r--r--files/zh-cn/web/api/location/reload/index.html109
-rw-r--r--files/zh-cn/web/api/location/replace/index.html71
-rw-r--r--files/zh-cn/web/api/location/search/index.html50
-rw-r--r--files/zh-cn/web/api/location/tostring/index.html42
10 files changed, 748 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/location/assign/index.html b/files/zh-cn/web/api/location/assign/index.html
new file mode 100644
index 0000000000..8bf9c358f8
--- /dev/null
+++ b/files/zh-cn/web/api/location/assign/index.html
@@ -0,0 +1,71 @@
+---
+title: Location.assign()
+slug: Web/API/Location/assign
+tags:
+ - API
+ - Location
+ - 参考
+ - 导航
+ - 方法
+ - 跳转
+translation_of: Web/API/Location/assign
+---
+<p>{{ APIRef("HTML DOM") }}</p>
+
+<p><code><strong>Location.assign()</strong></code> 方法会触发窗口加载并显示指定的URL的内容。</p>
+
+<p>如果由于安全原因无法执行跳转,那么会抛出一个 <code>SECURITY_ERROR</code> 类型的 {{domxref("DOMException")}}。当调用此方法的脚本来源和页面的 {{domxref("Location")}} 对象中定义的来源隶属于不同域的时候,就会抛出上述错误。</p>
+
+<p>如果传入了一个无效的 URL,则会抛出一个 <code>SYNTAX_ERROR</code> 类型的 {{domxref("DOMException")}}。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><var>location</var>.assign(<var>url</var>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>url</code></dt>
+ <dd>一个包含了要跳转到的链接的{{domxref("DOMString")}}。</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">// 跳转到 Location.reload() 这篇文章
+ document.location.assign('https://developer.mozilla.org/zh-CN/docs/Web/API/Location/reload');</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', "history.html#dom-location-assign", "Location.assign()")}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>和 {{SpecName("HTML5 W3C")}} 相同。</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', "browsers.html#dom-location-assign", "Location.assign()")}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td>第一次被定义。</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.Location.assign")}}</p>
+
+<h2 id="相关内容">相关内容</h2>
+
+<ul>
+ <li>父级接口 {{domxref("Location")}}。</li>
+ <li>相似的方法:{{domxref("Location.replace()")}} 和 {{domxref("Location.reload()")}}。</li>
+</ul>
diff --git a/files/zh-cn/web/api/location/hash/index.html b/files/zh-cn/web/api/location/hash/index.html
new file mode 100644
index 0000000000..0a0d45e220
--- /dev/null
+++ b/files/zh-cn/web/api/location/hash/index.html
@@ -0,0 +1,47 @@
+---
+title: 'Location: hash'
+slug: Web/API/Location/hash
+translation_of: Web/API/Location/hash
+---
+<div>{{ APIRef("Location") }}</div>
+
+<p><span class="seoSummary">{{domxref("Location")}} 接口的 <strong><code>hash</code></strong> 属性返回一个 {{domxref("USVString")}},其中会包含URL标识中的 <code>'#'</code> 和 后面URL片段标识符。</span></p>
+
+<p>这里 fragment 不会经过<a href="/en-US/docs/Glossary/percent-encoding">百分比编码</a>(URL编码)。如果 URL 中没有 fragment,该属性会包含一个空字符串,<code>""</code></p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox notranslate"><em>string</em> = <em>object</em>.hash;
+<em>object</em>.hash = <em>string</em>;
+</pre>
+
+<h2 id="Examples">Examples</h2>
+
+<pre class="brush: html notranslate">&lt;a id="myAnchor" href="/en-US/docs/Location.href#Examples"&gt;Examples&lt;/a&gt;
+&lt;script&gt;
+ var anchor = document.getElementById("myAnchor");
+ console.log(anchor.hash); // 返回'#Examples'
+&lt;/script&gt;</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', '#dom-location-hash', 'hash')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div class="hidden">本页面的兼容性表格是由结构化数据生成的。如果你愿意为这些数据做点贡献,请在 github <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 检出代码,然后发送 pull request 给我们。</div>
+
+<p>{{Compat("api.Location.hash")}}</p>
diff --git a/files/zh-cn/web/api/location/host/index.html b/files/zh-cn/web/api/location/host/index.html
new file mode 100644
index 0000000000..f4ab84da3d
--- /dev/null
+++ b/files/zh-cn/web/api/location/host/index.html
@@ -0,0 +1,52 @@
+---
+title: 'Location: host'
+slug: Web/API/Location/host
+translation_of: Web/API/Location/host
+---
+<div>{{ApiRef("Location")}}</div>
+
+<p>{{domxref("Location")}} 接口的 <strong><code>host</code></strong> 属性是包含了主机的一段 {{domxref("USVString")}},其中包含:主机名,如果 URL 的端口号是非空的,还会跟上一个 <code>':'</code> ,最后是 URL 的端口号。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox notranslate"><em>string</em> = <em>object</em>.host;
+<em>object.<code>host</code></em> = <em>string</em>;
+</pre>
+
+<h2 id="Examples">Examples</h2>
+
+<pre class="brush: js notranslate">var anchor = document.createElement("a");
+
+anchor.href = "https://developer.mozilla.org/en-US/Location.host"
+anchor.host == "developer.mozilla.org"
+
+anchor.href = "https://developer.mozilla.org:443/en-US/Location.host"
+anchor.host == "developer.mozilla.org"
+// 这里 <code>host </code>中没有包含端口号,因为 443 是 https协议的默认端口号
+
+anchor.href = "https://developer.mozilla.org:4097/en-US/Location.host"
+anchor.host == "developer.mozilla.org:4097"
+</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', '#dom-location-host', 'host')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("api.Location.host")}}</p>
diff --git a/files/zh-cn/web/api/location/hostname/index.html b/files/zh-cn/web/api/location/hostname/index.html
new file mode 100644
index 0000000000..20c424dcdf
--- /dev/null
+++ b/files/zh-cn/web/api/location/hostname/index.html
@@ -0,0 +1,43 @@
+---
+title: 'Location: hostname'
+slug: Web/API/Location/hostname
+translation_of: Web/API/Location/hostname
+---
+<p>{{ApiRef("URL API")}}</p>
+
+<p>{{domxref("Location")}}的 <strong><code>hostname</code></strong> 属性是包含了域名的一段 {{domxref("USVString")}}。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox notranslate"><em>string</em> = <em>object</em>.hostname;
+<em>object.</em>hostname = <em>string</em>;
+</pre>
+
+<h2 id="Examples">Examples</h2>
+
+<pre class="brush: js notranslate">// 在文档流中声明了一个元素: &lt;a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location.hostname"&gt;
+var anchor = document.getElementById("myAnchor");
+var result = anchor.hostname; // Returns:'developer.mozilla.org'</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', '#dom-location-hostname', 'hostname')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("api.Location.hostname")}}</p>
diff --git a/files/zh-cn/web/api/location/href/index.html b/files/zh-cn/web/api/location/href/index.html
new file mode 100644
index 0000000000..55b2cffb4f
--- /dev/null
+++ b/files/zh-cn/web/api/location/href/index.html
@@ -0,0 +1,44 @@
+---
+title: 'Location: href'
+slug: Web/API/Location/href
+translation_of: Web/API/Location/href
+---
+<p>{{ApiRef("Location")}}</p>
+
+<p>{{domxref("Location")}} 接口的 <strong><code>href</code></strong> 属性是一个字符串化转换器(stringifier), 返回一个包含了完整 URL 的 {{domxref("USVString")}} 值, 且允许 href 的更新.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>string</em> = <em>object</em>.href;
+<em>object</em>.href = <em>string</em>;
+</pre>
+
+<h2 id="范例">范例</h2>
+
+<pre class="brush: js">// 假设文档中包含标签: &lt;a id="myAnchor" href="https://developer.mozilla.org/en-US/Location/href"&gt;
+var anchor = document.getElementById("myAnchor");
+var result = anchor.href; // 返回: 'https://developer.mozilla.org/en-US/Location/href'
+</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', '#dom-location-href', 'href')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.Location.href")}}</p>
diff --git a/files/zh-cn/web/api/location/index.html b/files/zh-cn/web/api/location/index.html
new file mode 100644
index 0000000000..7ab82cf7fa
--- /dev/null
+++ b/files/zh-cn/web/api/location/index.html
@@ -0,0 +1,219 @@
+---
+title: Location
+slug: Web/API/Location
+tags:
+ - API
+ - Interface
+ - Location
+translation_of: Web/API/Location
+---
+<p>{{APIRef("URLUtils")}}</p>
+
+<p><strong><code>Location </code></strong>接口表示其链接到的对象的位置(URL)。所做的修改反映在与之相关的对象上。 {{domxref("Document")}} 和 {{domxref("Window")}} 接口都有这样一个链接的Location,分别通过 {{domxref("Document.location")}}和{{domxref("Window.location")}} 访问。</p>
+
+<h2 id="属性">属性</h2>
+
+<p><em><code>Location </code>接口</em><em>不继承任何属性,但是实现了那些来自 {{domxref("URLUtils")}} 的属性。</em></p>
+
+<dl>
+ <dt>{{domxref("Location.href")}}</dt>
+ <dd>包含整个URL的一个{{domxref("DOMString")}}</dd>
+ <dt>{{domxref("Location.protocol")}}</dt>
+ <dd>包含URL对应协议的一个{{domxref("DOMString")}},最后有一个":"。</dd>
+ <dt>{{domxref("Location.host")}}</dt>
+ <dd>包含了域名的一个{{domxref("DOMString")}},可能在该串最后带有一个":"并跟上URL的端口号。</dd>
+ <dt>{{domxref("Location.hostname")}}</dt>
+ <dd>包含URL域名的一个{{domxref("DOMString")}}。</dd>
+ <dt>{{domxref("Location.port")}}</dt>
+ <dd>包含端口号的一个{{domxref("DOMString")}}。</dd>
+ <dt>{{domxref("Location.pathname")}}</dt>
+ <dd>包含URL中路径部分的一个{{domxref("DOMString")}},开头有一个“<code>/"。</code></dd>
+ <dt>{{domxref("Location.search")}}</dt>
+ <dd> 包含URL参数的一个{{domxref("DOMString")}},开头有一个<code>“?”</code>。</dd>
+ <dt>{{domxref("Location.hash")}}</dt>
+ <dd>包含块标识符的{{domxref("DOMString")}},开头有一个<code>“#”。</code></dd>
+ <dt>{{domxref("Location.username")}}</dt>
+ <dd>包含URL中域名前的用户名的一个{{domxref("DOMString")}}。</dd>
+ <dt>{{domxref("Location.password")}}</dt>
+ <dd>包含URL域名前的密码的一个 {{domxref("DOMString")}}。</dd>
+ <dt>{{domxref("Location.origin")}} {{readOnlyInline}}</dt>
+ <dd>包含页面来源的域名的标准形式{{domxref("DOMString")}}。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<p><em><code>Location</code></em><em>没有继承任何方法<em>,但实现了来自{{domxref("URLUtils")}}</em>的方法。</em></p>
+
+<dl>
+ <dt>{{domxref("Location.assign()")}}</dt>
+ <dd>加载给定URL的内容资源到这个Location对象所关联的对象上。</dd>
+ <dt>{{domxref("Location.reload()")}}</dt>
+ <dd>重新加载来自当前 URL的资源。他有一个特殊的可选参数,类型为 {{domxref("Boolean")}},该参数为true时会导致该方法引发的刷新一定会从服务器上加载数据。如果是 <code>false</code>或没有制定这个参数,浏览器可能从缓存当中加载页面。</dd>
+ <dt>{{domxref("Location.replace()")}}</dt>
+ <dd>用给定的URL替换掉当前的资源。与 <code>assign()</code> 方法不同的是用 <code>replace()</code>替换的新页面不会被保存在会话的历史 {{domxref("History")}}中,这意味着用户将不能用后退按钮转到该页面。</dd>
+ <dt>{{domxref("Location.toString()")}}</dt>
+ <dd>返回一个{{domxref("DOMString")}},包含整个URL。 它和读取{{domxref("URLUtils.href")}}的效果相同。但是用它是不能够修改Location的值的。</dd>
+</dl>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush: js">// Create anchor element and use href property for the purpose of this example
+// A more correct alternative is to browse to the URL and use document.location or window.location
+var url = document.createElement('a');
+url.href = 'https://developer.mozilla.org/en-US/search?q=URL#search-results-close-container';
+console.log(url.href); // https://developer.mozilla.org/en-US/search?q=URL#search-results-close-container
+console.log(url.protocol); // https:
+console.log(url.host); // developer.mozilla.org
+console.log(url.hostname); // developer.mozilla.org
+console.log(url.port); // (blank - https assumes port 443)
+console.log(url.pathname); // /en-US/search
+console.log(url.search); // ?q=URL
+console.log(url.hash); // #search-results-close-container
+console.log(url.origin); // https://developer.mozilla.org
+</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#the-location-interface", "Location")}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>No change from {{SpecName("HTML5 W3C")}}.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', "browsers.html#the-location-interface", "Location")}}</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>特性</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>origin</code> on <code>Windows.location</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoDesktop("21")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>origin</code> on all <code>location</code> objects (but on Workers, that use {{domxref("WorkerLocation")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoDesktop("26")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>username</code> and <code>password</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoDesktop("26")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>searchParams</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoDesktop("34")}}</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>Firefox Mobile (Gecko)</th>
+ <th>IE Phone</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>
+ </tr>
+ <tr>
+ <td><code>origin</code> on <code>Windows.location</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile("21")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>origin</code> on all <code>location</code> objects (but on Workers, that use {{domxref("WorkerLocation")}})</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile("26")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>username</code> and <code>password</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile("26")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>searchParams</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile("34")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="另见">另见</h2>
+
+<ul>
+ <li>Two methods creating such an object: {{domxref("Window.location")}} and {{domxref("Document.location")}}.</li>
+</ul>
+
+<dl>
+ <dt> </dt>
+</dl>
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>
diff --git a/files/zh-cn/web/api/location/replace/index.html b/files/zh-cn/web/api/location/replace/index.html
new file mode 100644
index 0000000000..410036a441
--- /dev/null
+++ b/files/zh-cn/web/api/location/replace/index.html
@@ -0,0 +1,71 @@
+---
+title: Location.replace()
+slug: Web/API/Location/replace
+tags:
+ - API
+ - DOM
+ - Location
+ - 参考
+ - 导航
+ - 方法
+translation_of: Web/API/Location/replace
+---
+<p>{{ APIRef("Location") }}</p>
+
+<p><code><strong>Location</strong></code><strong><code>.replace()</code></strong> 方法以给定的URL来替换当前的资源。 与{{domxref("Location.assign","assign()")}} 方法 不同的是,调用 <code>replace()</code> 方法后,当前页面不会保存到会话历史中(session {{domxref("History")}}),这样,用户点击<em>回退</em>按钮时,将不会再跳转到该页面。</p>
+
+<p>因违反安全规则导致的赋值失败,浏览器将会抛出类型为 <code>SECURITY_ERROR</code> 的 {{domxref("DOMException")}} 异常。当调用该方法的脚本所属的源与拥有 {{domxref("Location")}} 对象所属源不同时,通常情况会发生这种异常,此时通常该脚本是存在不同的域下。</p>
+
+<p>如果 URL 无效,浏览器也会抛出 <code>SYNTAX_ERROR</code> 类型的 {{domxref("DOMException")}} 异常。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox notranslate"><em>object</em>.replace(<em>url</em>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>url</em></dt>
+ <dd> {{domxref("DOMString")}} 类型,指定所导航到的页面的 URL 地址。</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js notranslate">// Navigate to the Location.reload article by replacing this page
+window.location.replace('https://developer.mozilla.org/en-US/docs/Web/API/Location/reload');</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-replace", "Location.replace()")}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>No change from {{SpecName("HTML5 W3C")}}.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', "browsers.html#dom-location-replace", "Location.replace()")}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.Location.replace")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{domxref("Location")}} 对象。</li>
+ <li>类似方法: {{domxref("Location.assign()")}} 和 {{domxref("Location.reload()")}}。</li>
+</ul>
diff --git a/files/zh-cn/web/api/location/search/index.html b/files/zh-cn/web/api/location/search/index.html
new file mode 100644
index 0000000000..deb9fe589a
--- /dev/null
+++ b/files/zh-cn/web/api/location/search/index.html
@@ -0,0 +1,50 @@
+---
+title: 'Location: search'
+slug: Web/API/Location/search
+translation_of: Web/API/Location/search
+---
+<div>{{ApiRef("Location")}}</div>
+
+<p>{{domxref("Location")}} 接口的 <strong><code>search</code></strong> 属性会返回一段 {{domxref("USVString")}},其中包含一个URL标识中的 <code>'?'</code> 以及跟随其后的一串URL查询参数。</p>
+
+<p>现代浏览器提供 <code><a href="/en-US/docs/Web/API/URLSearchParams/get#Examples">URLSearchParams</a></code> 和 <code><a href="/en-US/docs/Web/API/URL/searchParams#Examples">URL.searchParams</a></code> 两个接口,使得从查询字符串中解析出查询参数变得更加容易。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox notranslate"><em>string</em> = <em>object</em>.search;
+<em>object</em>.search = <em>string</em>;
+</pre>
+
+<h2 id="Examples">Examples</h2>
+
+<pre class="brush: js notranslate">// 声明了一个 &lt;a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location.search?q=123"&gt; 元素在文档流中
+var anchor = document.getElementById("myAnchor");
+var queryString = anchor.search; // Returns:'?q=123'
+
+// 进一步解析:
+let params = new URLSearchParams(queryString);
+let q = parseInt(params.get("q")<span class="kwd">); // is the number 123</span>
+</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', '#dom-location-search', 'search')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("api.Location.search")}}</p>
diff --git a/files/zh-cn/web/api/location/tostring/index.html b/files/zh-cn/web/api/location/tostring/index.html
new file mode 100644
index 0000000000..84a5fdddff
--- /dev/null
+++ b/files/zh-cn/web/api/location/tostring/index.html
@@ -0,0 +1,42 @@
+---
+title: 'Location: toString()'
+slug: Web/API/Location/toString
+translation_of: Web/API/Location/toString
+---
+<p><font><font>{{ApiRef(“ Location”)}}</font></font></p>
+
+<p><strong><code>toString()</code></strong><font><font>{{domxref(“ Location”)}}接口</font><font>的</font><font>stringifier方法返回包含整个URL的{{domxref(“ USVString”)}}}。</font><font>它是{{domxref(“ Location.href”)}}的只读版本。</font></font></p>
+
+<h2 id="句法"><font><font>句法</font></font></h2>
+
+<pre class="syntaxbox notranslate"><em>string</em> = <em>object</em>.toString();</pre>
+
+<h2 id="例子"><font><font>例子</font></font></h2>
+
+<pre class="brush: js notranslate">// Let's imagine an &lt;a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location/toString"&gt; element is in the document
+var anchor = document.getElementById("myAnchor");
+var result = anchor.toString(); // Returns: 'https://developer.mozilla.org/en-US/docs/Location/toString'
+</pre>
+
+<h2 id="技术指标"><font><font>技术指标</font></font></h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col"><font><font>规范</font></font></th>
+ <th scope="col"><font><font>状态</font></font></th>
+ <th scope="col"><font><font>评论</font></font></th>
+ </tr>
+ <tr>
+ <td><font><font>{{SpecName('HTML WHATWG',“#dom-location-href”)}}</font></font></td>
+ <td><font><font>{{Spec2('HTML WHATWG')}}</font></font></td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性"><font><font>浏览器兼容性</font></font></h2>
+
+<div class="hidden"><font><font>此页面上的兼容性表是根据结构化数据生成的。</font><font>如果您想贡献数据,请查看</font></font><a href="https://github.com/mdn/browser-compat-data"><font><font>https://github.com/mdn/browser-compat-data</font></font></a><font><font>并向我们​​发送请求请求。</font></font></div>
+
+<p><font><font>{{Compat(“ api.Location.toString”)}}</font></font></p>