aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/htmlanchorelement/referrerpolicy/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/htmlanchorelement/referrerpolicy/index.html')
-rw-r--r--files/zh-cn/web/api/htmlanchorelement/referrerpolicy/index.html116
1 files changed, 116 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlanchorelement/referrerpolicy/index.html b/files/zh-cn/web/api/htmlanchorelement/referrerpolicy/index.html
new file mode 100644
index 0000000000..b3e30b3fe2
--- /dev/null
+++ b/files/zh-cn/web/api/htmlanchorelement/referrerpolicy/index.html
@@ -0,0 +1,116 @@
+---
+title: HTMLAnchorElement.referrer
+slug: Web/API/HTMLAnchorElement/referrer
+translation_of: Web/API/HTMLAnchorElement/referrerPolicy
+---
+<div>{{APIRef}}{{SeeCompatTable}}</div>
+
+<p><code><strong>HTMLAnchorElement</strong></code><strong><code>.referrer</code></strong> 属性对应于 HTML 中 {{HTMLElement("a")}} 标签的 {{htmlattrxref("referrer","a")}} 属性,它可以控制用户在点击这个链接时所发出的 HTTP 请求的 Referer 请求头的值。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><var>refStr</var> = <var>anchorElt</var>.referrer;
+<var>anchorElt</var>.referrer = <var>refStr</var>;</pre>
+
+<h3 id="属性值">属性值</h3>
+
+<dl>
+ <dd>
+ <ul>
+ <li><code>"no-referrer"</code> 意味着不要发送 Referer 请求头。</li>
+ <li><code>"origin"</code>  意味着所发送的 Referer 请求头的值为当前页面的源,即 <code>location.origin</code> 的值。</li>
+ <li><code>"unsafe-url"</code> 意味着所发送的 Referrer 请求头的值为当前页面完整的 url(即<code> location.href</code>)去掉尾部的哈希(即 <code>location.hash</code>)之后的值。正如该选项的名字所言(unsafe),此选项是不安全的,它可以将一个 HTTPS 页面的路径信息透露给第三方。</li>
+ </ul>
+ </dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">var elt = document.createElement("a");
+var linkText = document.createTextNode("My link");
+elt.appendChild(linkText);
+elt.href = "https://developer.mozilla.org/en-US/";
+elt.referrer = "no-referrer";
+
+var div = document.getElementById("divAround");
+div.appendChild(elt); // 点击该链接接时不会发送 Referer 请求头
+</pre>
+
+<h2 id="Specifications" name="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('Referrer Policy', '#referrer-policy-delivery-referrer-attribute', 'referrer attribute')}}</td>
+ <td>{{Spec2('Referrer Policy')}}</td>
+ <td>Added the <code>referrer</code> attribute.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>{{CompatibilityTable}}
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Edge</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoDesktop("42.0")}} [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>Firefox Mobile (Gecko)</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile("42.0")}} [1]</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] 该特性目前默认为关闭状态,请通过将 <code>network.http.enablePerElementReferrer</code> 选项设置为 <code>true</code> 来开启。</p>
+</div>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li>{{domxref("HTMLImageElement.referrer")}}、{{domxref("HTMLAreaElement.referrer")}}、{{domxref("HTMLIFrameElement.referrer")}}</li>
+</ul>