diff options
author | MDN <actions@users.noreply.github.com> | 2021-03-24 00:27:57 +0000 |
---|---|---|
committer | MDN <actions@users.noreply.github.com> | 2021-03-24 00:27:57 +0000 |
commit | 8d7ad7715e19a445def22de6d5f3d9519cebe69e (patch) | |
tree | dfeab89fe885baadfaa3629850e4dbf53a9a8669 /files/zh-cn/conflicting/web/api | |
parent | 0511ab6f682be0c8401377e50cd4a164e87ec589 (diff) | |
download | translated-content-8d7ad7715e19a445def22de6d5f3d9519cebe69e.tar.gz translated-content-8d7ad7715e19a445def22de6d5f3d9519cebe69e.tar.bz2 translated-content-8d7ad7715e19a445def22de6d5f3d9519cebe69e.zip |
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/conflicting/web/api')
3 files changed, 281 insertions, 0 deletions
diff --git a/files/zh-cn/conflicting/web/api/element/localname/index.html b/files/zh-cn/conflicting/web/api/element/localname/index.html new file mode 100644 index 0000000000..6d5f5f26b6 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/element/localname/index.html @@ -0,0 +1,65 @@ +--- +title: Node.localName +slug: conflicting/Web/API/Element/localName +translation_of: Web/API/Node/localName +original_slug: Web/API/Node/localName +--- +<div> + {{ApiRef}}</div> +<h2 id="Summary" name="Summary">Summary</h2> +<p>Returns the local part of the qualified name of this node.</p> +<h2 id="Syntax" name="Syntax">Syntax</h2> +<pre class="syntaxbox"><var>name</var> = <var>element</var>.localName +</pre> +<ul> + <li><code>name</code> is the local name as a string (see {{Anch("Notes")}} below for details)</li> +</ul> +<h2 id="Example" name="Example">Example</h2> +<p>(Must be served with XML content type, such as <code>text/xml</code> or <code>application/xhtml+xml</code>.)</p> +<pre class="brush:xml"><html xmlns="http://www.w3.org/1999/xhtml" + xmlns:svg="http://www.w3.org/2000/svg"> +<head> + <script type="application/javascript"><![CDATA[ + function test() { + var text = document.getElementById('text'); + var circle = document.getElementById('circle'); + + text.value = "<svg:circle> has:\n" + + "localName = '" + circle.localName + "'\n" + + "namespaceURI = '" + circle.namespaceURI + "'"; + } + ]]></script> +</head> +<body onload="test()"> + <svg:svg version="1.1" + width="100px" height="100px" + viewBox="0 0 100 100"> + <svg:circle cx="50" cy="50" r="30" style="fill:#aaa" id="circle"/> + </svg:svg> + <textarea id="text" rows="4" cols="55"/> +</body> +</html> +</pre> +<h2 id="Notes" name="Notes">Notes</h2> +<p>The local name of a node is that part of the node's qualified name that comes after the colon. Qualified names are typically used in XML as part of the namespace(s) of the particular XML documents. For example, in the qualified name <code>ecomm:partners</code>, <code>partners</code> is the local name and <code>ecomm</code> is the prefix:</p> +<pre class="brush:xml"><ecomm:business id="soda_shop" type="brick_n_mortar" xmlns:ecomm="http://example.com/ecomm"> + <ecomm:partners> + <ecomm:partner id="1001">Tony's Syrup Warehouse + </ecomm:partner> + </ecomm:partner> +</ecomm:business> +</pre> + +<div class="note"> + <p><strong>Note:</strong> In {{Gecko("1.9.2")}} and earlier, the property returns the upper-cased version of the local name for HTML elements in HTML DOMs (as opposed to XHTML elements in XML DOMs). In later versions, in compliance with HTML5, the property returns in the case of the internal DOM storage, which is lower case for both HTML elements in HTML DOMs and XHTML elements in XML DOMs. The {{domxref("element.tagName","tagName")}} property continues to return in the upper case for HTML elements in HTML DOMs.</p> +</div> +<p>For nodes of any <a href="/zh-CN/docs/DOM/Node.nodeType" title="DOM/Node.nodeType">type</a> other than <code>ELEMENT_NODE</code> and <code>ATTRIBUTE_NODE</code> <code>localName</code> is always <code>null</code>.</p> +<h2 id="Specification" name="Specification">Specification</h2> +<ul> + <li><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-NodeNSLocalN">DOM Level 2 Core: Node.localName</a></li> + <li><a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-NodeNSLocalN">DOM Level 3 Core: Node.localName</a></li> +</ul> +<h2 id="See_also" name="See_also">See also</h2> +<ul> + <li>{{domxref("Node.namespaceURI")}}</li> +</ul> diff --git a/files/zh-cn/conflicting/web/api/element/namespaceuri/index.html b/files/zh-cn/conflicting/web/api/element/namespaceuri/index.html new file mode 100644 index 0000000000..b2f0fa1e38 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/element/namespaceuri/index.html @@ -0,0 +1,139 @@ +--- +title: Node.namespaceURI +slug: conflicting/Web/API/Element/namespaceURI +translation_of: Web/API/Node/namespaceURI +original_slug: Web/API/Node/namespaceURI +--- +<div>{{APIRef("DOM")}}{{obsolete_header}}</div> + +<p><code><strong>Node.namespaceURI</strong></code> 是一个只读属性,返回节点的命名空间URI(namespace URI),如果节点不在一个命名空间中,则返回 <code>null</code>。当节点是文档节点时,返回当前文档的 XML 命名空间(namespace)。</p> + +<div class="warning"> +<p>在 DOM4 中, 此接口从<code>Node</code> 被移入 {{domxref("Element")}} 和 {{domxref("Attr")}}接口.</p> +</div> + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre class="syntaxbox"><em>namespace</em> = <em>node</em>.namespaceURI</pre> + +<h2 id="Example" name="Example">示例</h2> + +<p>在这个示例中, 使用 <a href="/en-US/docs/DOM/Node.localName" title="DOM/Node.localName">localName</a> 和 <code>namespaceURI来检查这个node</code>. 如果 <code>namespaceURI</code> 返回 XUL 命名空间并且 <code>localName</code> 返回 "browser", 说明这个节点属于 XUL <code><browser/></code>.</p> + +<pre class="brush:js">if (node.localName == "browser" && + node.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul") { + // this is a XUL browser +}</pre> + +<h2 id="Notes" name="Notes">备注</h2> + +<p>这不是一个计算值,它是基于检查范围内的命名空间声明的名称空间查找的结果。节点的命名空间URI在节点创建时被固定。</p> + +<p>在Firefox 3.5或更早的版本中,HTML文档中HTML元素的名称空间URI是<code>null</code>。在之后的版本中,由<code><a class="external" href="http://www.w3.org/1999/xhtml" rel="freelink">http://www.w3.org/1999/xhtml</a></code> 作为XHTML,符合HTML5. {{gecko_minversion_inline("1.9.2")}}</p> + +<p>除了<code>ELEMENT_NODE</code> a和 <code>ATTRIBUTE_NODE</code> 以外的 <a href="/en-US/docs/DOM/Node.nodeType" title="DOM/Node/NodeType/Node.nodeType">nodeType</a> 中 node 的 <code>namespaceURI</code> 永远是<code>null</code>.</p> + +<p>你可以使用DOM2的方法 <a href="/en-US/docs/DOM/document.createElementNS" title="DOM/document.createElementNS">document.createElementNS</a> 来创建一个有特殊 <code>namespaceURI</code> 的元素.</p> + +<p>在<a class="external" href="http://www.w3.org/TR/xml-names11/">XML的命名空间</a>中,属性不会从它附加到的元素继承它的命名空间。如果属性未显式地给出命名空间,则它没有命名空间.</p> + +<p>DOM本身不处理或执行命名空间验证, 因此应该有由DOM应用程序进行必要的验证。请注意,命名空间前缀一旦与特定节点关联,则不能更改.</p> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">备注</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("DOM3 Core", "core.html#ID-NodeNSname", "Node.namespaceURI")}}</td> + <td>{{Spec2("DOM3 Core")}}</td> + <td>当设置为 <code>null</code> 是指定动作.</td> + </tr> + <tr> + <td>{{SpecName("DOM2 Core", "core.html#Namespaces-Considerations", "DOM Level 2 Core: XML Namespaces")}}</td> + <td>{{Spec2("DOM2 Core")}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("DOM2 Core", "core.html#ID-NodeNSname", "Node.namespaceURI")}}</td> + <td>{{Spec2("DOM2 Core")}}</td> + <td>初始化</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>特征</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>是否支持</td> + <td>{{CompatVersionUnknown}}<br> + {{CompatNo}}46.0<sup>[1]</sup></td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}<sup>[2]</sup><br> + {{CompatNo}} {{CompatGeckoDesktop("48.0")}}<sup>[1]</sup></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>特征</th> + <th>Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>是否支持</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}<sup>[2]</sup><br> + {{CompatNo}} {{CompatGeckoMobile("48.0")}}<sup>[1]</sup></td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] 从DOM4标准开始, 此接口被移入{{domxref("Element")}} 和 {{domxref("Attr")}} 接口.</p> + +<p>[2] 在 Gecko 5.0 之前 {{geckoRelease("5.0")}}, 这是一个读写属性; 从 Gecko 5.0 起,这是一个只读属性, 符合标准.</p> + +<h2 id="参考">参考</h2> + +<ul> + <li>{{domxref("Node.localName")}}</li> + <li>{{domxref("Node.prefix")}}</li> + <li>{{domxref("Element.namespaceURI")}}</li> + <li>{{domxref("Attr.namespaceURI")}}</li> +</ul> diff --git a/files/zh-cn/conflicting/web/api/element/prefix/index.html b/files/zh-cn/conflicting/web/api/element/prefix/index.html new file mode 100644 index 0000000000..06c46e0ad9 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/element/prefix/index.html @@ -0,0 +1,77 @@ +--- +title: Node.prefix +slug: conflicting/Web/API/Element/prefix +translation_of: Web/API/Node/prefix +original_slug: Web/API/Node/prefix +--- +<div> + {{ApiRef}}</div> +<h2 id="Summary" name="Summary">概述</h2> +<p><code>prefix属性会</code>返回当前节点的命名空间前缀,如果没有指定命名空间前缀,则返回<code>null</code>,该属性只读.</p> +<h2 id="Syntax" name="Syntax">语法</h2> +<pre class="syntaxbox"><var>string</var> = element.prefix +</pre> +<h2 id="Examples" name="Examples">示例</h2> +<p>下面的代码将弹出"x".</p> +<pre class="brush:xml"><x:div onclick="alert(this.prefix)"/> +</pre> +<h2 id="Notes" name="Notes">附注</h2> +<p>该属性只在一个解析命名空间前缀的文档中可用,也就是说,只有在文档的MIME类型为XML,XHTML,XUL时可用,在HTML文档中不可用.</p> +<h2 id="Specification" name="Specification">规范</h2> +<ul> + <li><a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-NodeNSPrefix">Node.prefix</a> (introduced in DOM2)</li> +</ul> +<h2 id="浏览器兼容性">浏览器兼容性</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</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatUnknown}}</td> + <td> + <p>{{CompatVersionUnknown}}</p> + <p>在Gecko 5.0 (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2)之前,该属性是可写的; 之后,是只读的.</p> + </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 Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatUnknown}}</td> + <td> + <p>{{CompatVersionUnknown}}</p> + <p>P在Gecko 5.0 (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2)之前,该属性是可写的; 之后,是只读的.</p> + </td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> + </table> +</div> +<p></p> |