diff options
Diffstat (limited to 'files/zh-cn/web/api/htmlimageelement/referrerpolicy/index.html')
-rw-r--r-- | files/zh-cn/web/api/htmlimageelement/referrerpolicy/index.html | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlimageelement/referrerpolicy/index.html b/files/zh-cn/web/api/htmlimageelement/referrerpolicy/index.html new file mode 100644 index 0000000000..c670d136f3 --- /dev/null +++ b/files/zh-cn/web/api/htmlimageelement/referrerpolicy/index.html @@ -0,0 +1,120 @@ +--- +title: HTMLImageElement.referrerPolicy +slug: Web/API/HTMLImageElement/referrerPolicy +translation_of: Web/API/HTMLImageElement/referrerPolicy +--- +<div>{{APIRef}}{{SeeCompatTable}}</div> + + + +<p><code><strong>HTMLImageElement</strong></code><strong><code>.referrerPolicy</code></strong> 反映了 {{HTMLElement("img")}} 元素的HTML属性 {{htmlattrxref("referrerpolicy","img")}} 的定义,这个属性定义了{{HTMLElement("img")}} 元素在获取资源时的引用方式。</p> + + + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><var>refStr</var> = <var>imgElt</var>.referrerPolicy; +<var>imgElt</var>.referrerPolicy = <var>refStr</var>;</pre> + +<h3 id="值">值</h3> + +<dl> + <dd> + <ul> + <li><code>"no-referrer"</code> 表示HTTP头部信息将不会发送 <code>referrer</code> 。</li> + <li><code>"origin"</code> 表示 referrer 只包含策略、主机名、端口等页面源的信息。</li> + <li><code>"unsafe-url"</code> 这意味着引用者将包括源站和路径(但不包括片段、密码或用户名)。这种情况是不安全的,因为它可能会泄漏路径信息,这些信息已被使用TLS隐藏到第三方。</li> + </ul> + </dd> +</dl> + +<h2 id="例子">例子</h2> + +<pre class="brush: js;highlight:[3]">var img = new Image(); +img.src = 'img/logo.png'; +img.referrerPolicy = 'origin'; + +var div = document.getElementById('divAround'); +div.appendChild(img); // Fetch the image using the origin as the referrer +</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', 'referrerPolicy attribute')}}</td> + <td>{{Spec2('Referrer Policy')}}</td> + <td>Added the <code>referrerPolicy</code> property.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> + +<p>{{CompatibilityTable}}</p> + +<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>{{CompatChrome("51")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop("50.0")}} [1]</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatOpera("38")}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android Webview</th> + <th>Chrome for 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>{{CompatChrome("51")}}</td> + <td>{{CompatChrome("51")}}</td> + <td>{{CompatGeckoMobile("50.0")}} [1]</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] 从火狐45到50,这都是在network.http.enableperelementerfer首选项之后。从火狐42到44,这个属性被称为referer。</p> + +<h2 id="相关">相关</h2> + +<ul> + <li>{{domxref("HTMLAnchorElement.referrerPolicy")}}, {{domxref("HTMLAreaElement.referrerPolicy")}}, and {{domxref("HTMLIFrameElement.referrerPolicy")}}.</li> +</ul> |