diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/htmlanchorelement | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/htmlanchorelement')
3 files changed, 369 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlanchorelement/download/index.html b/files/zh-cn/web/api/htmlanchorelement/download/index.html new file mode 100644 index 0000000000..1d8c763510 --- /dev/null +++ b/files/zh-cn/web/api/htmlanchorelement/download/index.html @@ -0,0 +1,48 @@ +--- +title: HTMLAnchorElement.download +slug: Web/API/HTMLAnchorElement/download +tags: + - HTML属性 + - 下载 +translation_of: Web/API/HTMLAnchorElement/download +--- +<div>{{APIRef("HTML DOM")}}</div> + +<p><code><strong>HTMLAnchorElement.download</strong></code>属性是一个{{jsxref("DOMString")}} ,表明链接的资源将被下载,而不是显示在浏览器中。该值表示下载文件的建议名称。如果该名称不是基础操作系统的有效文件名,浏览器将对其进行调整。</p> + +<div class="blockIndicator note"> +<p><strong>注意</strong>: 该值对于下载行为来说不一定是有用的,同时也不能决定下载行为是否发生。</p> +</div> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox notranslate">var <em>dnload</em> = <em>anchorElt</em>.download; +<em>anchorElt</em>.download = <em>dnload</em>; +</pre> + +<h2 id="规范Edit">规范<a class="button section-edit only-icon" href="https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLImageElement$edit#规范" rel="nofollow, noindex"><span>Edit</span></a></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('HTML WHATWG', 'multipage/text-level-semantics.html#dom-a-download', 'download')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>No change from {{SpecName("DOM2 HTML")}}</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器的兼容性">浏览器的兼容性</h2> + +<div> +<div class="hidden">此页上的兼容性表是由结构化数据生成的。如果您想对数据作出贡献,请检查 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> ,并向我们发送一个拉请求。</div> + +<p>{{Compat("api.HTMLAnchorElement.download")}}</p> +</div> diff --git a/files/zh-cn/web/api/htmlanchorelement/index.html b/files/zh-cn/web/api/htmlanchorelement/index.html new file mode 100644 index 0000000000..a5e8a72584 --- /dev/null +++ b/files/zh-cn/web/api/htmlanchorelement/index.html @@ -0,0 +1,205 @@ +--- +title: HTMLAnchorElement +slug: Web/API/HTMLAnchorElement +translation_of: Web/API/HTMLAnchorElement +--- +<div>{{APIRef("HTML DOM")}}</div> + +<p><strong><code>HTMLAnchorElement</code></strong> 接口表示超链接元素,并提供一些特别的属性和方法(除了那些继承自普通 {{domxref("HTMLElement")}}对象接口的之外)以用于操作这些元素的布局和显示。</p> + +<h2 id="属性(Properties)">属性(Properties)</h2> + +<p><em>继承其父类 {{domxref("HTMLElement")}} 的属性,并实现 {{domxref("URLUtils")}} 中(定义)的(属性)。</em></p> + +<dl> + <dt>{{domxref("HTMLAnchorElement.accessKey")}}</dt> + <dd>是一个代表了单个字符的 {{domxref("DOMString")}},单个字符可以切换输入焦点到超链接。</dd> + <dt>{{domxref("HTMLAnchorElement.charset")}} {{obsolete_inline}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the character encoding of the linked resource.</dd> + <dt>{{domxref("HTMLAnchorElement.coords")}} {{obsolete_inline}}</dt> + <dd>Is a {{domxref("DOMString")}} representing a comma-separated list of coordinates.</dd> + <dt>{{domxref("HTMLAnchorElement.download")}} {{experimental_inline}}</dt> + <dd>Is a {{domxref("DOMString")}} indicating that the linked resource is intended to be downloaded rather than displayed in the browser. The value represent the proposed name of the file. If the name is not a valid filename of the underlying OS, browser will adapt it. The value is a URL with a scheme like <code>http:</code>, <code>file:</code>, <code>data:</code> or even <code>blob:</code> (created with {{domxref("URL.createObjectURL")}}).</dd> + <dt>{{domxref("URLUtils.hash")}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the fragment identifier, including the leading hash mark ('<code>#</code>'), if any, in the referenced URL.</dd> + <dt>{{domxref("URLUtils.host")}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the hostname and port (if it's not the default port) in the referenced URL.</dd> + <dt>{{domxref("URLUtils.hostname")}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the hostname in the referenced URL.</dd> + <dt>{{domxref("URLUtils.href")}}</dt> + <dd>Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("href", "a")}} HTML attribute, containing a valid URL of a linked resource.</dd> + <dt>{{domxref("HTMLAnchorElement.hreflang")}}</dt> + <dd>Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("hreflang", "a")}} HTML attribute, indicating the language of the linked resource.</dd> + <dt>{{domxref("HTMLAnchorElement.media")}}</dt> + <dd>Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("media", "a")}} HTML attribute, indicating the intended media for the linked resource.</dd> + <dt>{{domxref("HTMLAnchorElement.name")}} {{obsolete_inline}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the anchor name.</dd> + <dt>{{domxref("URLUtils.passport")}}</dt> + <dd>Is a {{domxref("DOMString")}} 包含指定域名的密码。</dd> + <dt>{{domxref("URLUtils.origin")}} {{readonlyInline}}</dt> + <dd>Returns a {{domxref("DOMString")}} containing the origin of the URL, that is its scheme, its domain and its port.</dd> + <dt>{{domxref("URLUtils.pathname")}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the path name component, if any, of the referenced URL.</dd> + <dt>{{domxref("URLUtils.port")}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the port component, if any, of the referenced URL.</dd> + <dt>{{domxref("URLUtils.protocol")}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the protocol component, including trailing colon ('<code>:</code>'), of the referenced URL.</dd> + <dt>{{domxref("HTMLAnchorElement.rel")}}</dt> + <dd>Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("rel", "a")}} HTML attribute, specifying the relationship of the target object to the linked object.</dd> + <dt>{{domxref("HTMLAnchorElement.relList")}} {{readonlyInline}}</dt> + <dd>Returns a {{domxref("DOMTokenList")}} that reflects the {{htmlattrxref("rel", "a")}} HTML attribute, as a list of tokens.</dd> + <dt>{{domxref("HTMLAnchorElement.rev")}} {{obsolete_inline}}</dt> + <dd>Is a {{domxref("DOMString")}} representing that the {{htmlattrxref("rev", "a")}} HTML attribute, specifying the relationship of the link object to the target object.</dd> + <dt>{{domxref("URLUtils.search")}}</dt> + <dd>Is a {{domxref("DOMString")}} representing tThe search element, including leading question mark ('<code>?</code>'), if any, of the referenced URL.</dd> + <dt>{{domxref("HTMLAnchorElement.shape")}} {{obsolete_inline}}</dt> + <dd>Is a {{domxref("DOMString")}} representing the shape of the active area.</dd> + <dt>{{domxref("HTMLAnchorElement.tabindex")}}</dt> + <dd>Is a <code>long</code> containing the position of the element in the tabbing navigation order for the current document.</dd> + <dt>{{domxref("HTMLAnchorElement.target")}}</dt> + <dd>Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("target", "a")}} HTML attribute, indicating where to display the linked resource.</dd> + <dt>{{domxref("HTMLAnchorElement.text")}}</dt> + <dd>Is a {{domxref("DOMString")}} being a synonym for the {{domxref("Node.textContent")}} property.</dd> + <dt>{{domxref("HTMLAnchorElement.type")}}</dt> + <dd>Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("type", "a")}} HTML attribute, indicating the MIME type of the linked resource.</dd> + <dt>{{domxref("URLUtils.username")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing the username specified before the domain name.</dd> +</dl> + +<h2 id="Methods">Methods</h2> + +<p><em>Inherits methods from its parent, {{domxref("HTMLElement")}}, </em><em>and implements those from {{domxref("URLUtils")}}</em><em>.</em></p> + +<dl> + <dt>{{domxref("HTMLElement.blur()")}}</dt> + <dd>Removes the keyboard focus from the current element.</dd> + <dt>{{domxref("HTMLElement.focus()")}}</dt> + <dd>Gives the keyboard focus to the current element.</dd> + <dt>{{domxref("URLUtils.toString()")}}</dt> + <dd>Returns a {{domxref("DOMString")}} containing the whole URL. It is a synonym for {{domxref("URLUtils.href")}}, though it can't be used to modify the value.</dd> +</dl> + +<p>The <code>blur()</code> and <code>focus()</code> methods are inherited from {{domxref("HTMLElement")}} from HTML5 on, but were defined on <code>HTMLAnchorElement</code> in DOM Level 2 HTML and earlier specifications.</p> + +<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', "text-level-semantics.html#the-a-element", "HTMLAnchorElement")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>The following property has been added: <code>download</code>.<br> + Technically, the URL-related properties, <code>media</code>, <code>host</code>, <code>hostname</code>, <code>pathname</code>, <code>port</code>, <code>protocol</code>, <code>search</code>, and <code>hash</code>, have been moved to the {{domxref("URLUtils")}} interface, and <code>HTMLAreaElement</code> implements this interface.</td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', "text-level-semantics.html#the-a-element", "HTMLAnchorElement")}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td>The methods <code>blur()</code> and <code>focus()</code>, as well as the properties <code>tabindex</code> and <code>accessKey</code>, are now defined on {{domxref("HTMLElement")}}.<br> + The following properties are now obsolete: <code>charset</code>, <code>coords</code>, <code>name</code>, <code>rev</code>, and <code>shape</code>.<br> + The following properties have been added: <code>hash</code>, <code>host</code>, <code>hostname</code>, <code>media</code>, <code>pathname</code>, <code>port</code>, <code>protocol</code>, <code>relList</code>, <code>search</code>, and <code>text</code>.</td> + </tr> + <tr> + <td>{{SpecName('DOM2 HTML', 'html.html#ID-48250443', 'HTMLAnchorElement')}}</td> + <td>{{Spec2('DOM2 HTML')}}</td> + <td>No change from {{SpecName("DOM1")}}.</td> + </tr> + <tr> + <td>{{SpecName('DOM1', 'level-one-html.html#ID-48250443', 'HTMLAnchorElement')}}</td> + <td>{{Spec2('DOM1')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<div>{{CompatibilityTable}}</div> + +<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 (WebKit)</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop(1.0)}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + <tr> + <td><code>download</code></td> + <td>14</td> + <td>20</td> + <td>{{CompatUnknown}}</td> + <td>15</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>username</code>, <code>password</code>, and <code>origin</code></td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop("26.0")}}</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>{{CompatGeckoMobile(1.0)}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + <tr> + <td><code>download</code></td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>username</code>, <code>password</code>, and <code>origin</code></td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoMobile("26.0")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li>The HTML element implementing this interface: {{HTMLElement("a")}}</li> +</ul> diff --git a/files/zh-cn/web/api/htmlanchorelement/referrer/index.html b/files/zh-cn/web/api/htmlanchorelement/referrer/index.html new file mode 100644 index 0000000000..b3e30b3fe2 --- /dev/null +++ b/files/zh-cn/web/api/htmlanchorelement/referrer/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> |