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/javascript/reference/global_objects/string/anchor | |
| 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/javascript/reference/global_objects/string/anchor')
| -rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/string/anchor/index.html | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/anchor/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/anchor/index.html new file mode 100644 index 0000000000..0b3a4169cd --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/string/anchor/index.html @@ -0,0 +1,136 @@ +--- +title: String.prototype.anchor() +slug: Web/JavaScript/Reference/Global_Objects/String/anchor +tags: + - HTML + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/anchor +--- +<div>{{JSRef("Global_Objects", "String")}}</div> + +<h2 id="概述">概述</h2> + +<div class="blockIndicator warning"> +<p>已废弃<br> + 该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。</p> +</div> + +<p><code><strong>anchor()</strong></code> 方法创建一个 {{HTMLElement("a")}} HTML 锚元素,被用作超文本靶标(hypertext target)。</p> + +<p id="Syntax">语法</p> + +<pre class="syntaxbox"><code>str.anchor(<em>name</em>) </code></pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><code>name</code></dt> + <dd>一个字符串,表示被创建的标签的 <code>name</code> 属性。</dd> +</dl> + +<h3 id="返回值">返回值</h3> + +<p> 包含 {{HTMLElement("a")}} HTML元素的一个字符串。</p> + +<h2 id="描述">描述</h2> + +<p>使用 <code>anchor</code> 方法能够以编程方式在一个文档中创建和展现一个锚链接。</p> + +<p>语法上来讲,字符串表示你想让用户看到的文本。<code>name</code> 字符串参数表示 {{HTMLElement("a")}} 元素的 <code>name</code> 属性。</p> + +<p>使用 anchor 方法创建的锚点(anchors)将会成为 {{domxref("document.anchors")}} 数组的元素。</p> + +<h2 id="示例">示例</h2> + +<h3 id="例子:使用_anchor">例子:使用 <code>anchor</code></h3> + +<pre class="brush:js">var myString = "Table of Contents"; + +document.body.innerHTML = myString.anchor("contents_anchor");</pre> + +<p>将会输出下面的 HTML:</p> + +<pre class="brush: html"><a name="contents_anchor">Table of Contents</a></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('ES6', '#sec-string.prototype.anchor', 'String.prototype.anchor')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Initial definition. Implemented in JavaScript 1.0.<br> + Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</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>{{ CompatGeckoDesktop("1.0") }}</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>{{ CompatGeckoMobile("1.0") }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<h3 id="Gecko-specific_notes">Gecko-specific notes</h3> + +<p>从{{gecko("17")}}开始 <strong>"</strong> (引号) 被 HTML引用字符 <code>&quot所替代</code>;在字符串中申请<code>命名参数</code>.</p> + +<h2 id="See_Also" name="See_Also">相关链接</h2> + +<ul> + <li>{{jsxref("String.prototype.link()")}}</li> +</ul> |
