aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/domimplementation/createdocument/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/domimplementation/createdocument/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/domimplementation/createdocument/index.html')
-rw-r--r--files/zh-cn/web/api/domimplementation/createdocument/index.html83
1 files changed, 83 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/domimplementation/createdocument/index.html b/files/zh-cn/web/api/domimplementation/createdocument/index.html
new file mode 100644
index 0000000000..59ccafd853
--- /dev/null
+++ b/files/zh-cn/web/api/domimplementation/createdocument/index.html
@@ -0,0 +1,83 @@
+---
+title: DOMImplementation.createDocument()
+slug: Web/API/DOMImplementation/createDocument
+translation_of: Web/API/DOMImplementation/createDocument
+---
+<p>{{ApiRef("DOM")}}</p>
+
+<p><strong><code>DOMImplementation.createDocument()</code>方法创建并返回一个</strong> {{domxref("XMLDocument")}}对象.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>doc</em> = document.implementation.createDocument(<em>namespaceURI</em>, <em>qualifiedNameStr</em>, <em>documentType</em>);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>namespaceURI</em></dt>
+ <dd>被创建的{{domxref("DOMString")}} 文档的namespace URI 是namespace URI ,如果文档不属于任何namespace URI 就为<code>null</code>.</dd>
+</dl>
+
+<dl>
+ <dt><em>qualifiedNameStr </em></dt>
+ <dd> {{domxref("DOMString")}} 是否包含要创建文档的限定名称,即可选的前缀和冒号,以及本地的根元素。</dd>
+</dl>
+
+<dl>
+ <dt><em>documentType </em>{{optional_inline}}</dt>
+ <dd>文档的 <code><a class="internal" href="/En/DOM/DocumentType" title="En/DOM/DocumentType">DocumentType</a> </code>默认为null.</dd>
+</dl>
+
+<ul>
+</ul>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush: js">var doc = document.implementation.createDocument ('http://www.w3.org/1999/xhtml', 'html', null);
+var body = document.createElementNS('http://www.w3.org/1999/xhtml', 'body');
+body.setAttribute('id', 'abc');
+doc.documentElement.appendChild(body);
+alert(doc.getElementById('abc')); // [object HTMLBodyElement]
+</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('DOM WHATWG', '#dom-domimplementation-createdocument', 'DOMImplementation.createDocument')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}[现时标准]</td>
+ <td>
+ <p>将<code>createDocument()</code> 的返回类型从 {{domxref("Document")}} 修改为{{domxref("XMLDocument")}}.<br>
+ <code>createDocument()</code>的第三个参数,文档类型,现在是可选的,默认为<code>null</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM3 Core', 'core.html#Level-2-Core-DOM-createDocument', 'DOMImplementation.createDocument')}}</td>
+ <td>{{Spec2('DOM3 Core')}}[过时]</td>
+ <td>自{{SpecName("DOM2 Core")}}无改变</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 Core', 'core.html#Level-2-Core-DOM-createDocument', 'DOMImplementation.createDocument')}}</td>
+ <td>{{Spec2('DOM2 Core')}}[过时]</td>
+ <td>初始定义.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器支持">浏览器支持</h2>
+
+<div class="hidden">本页的兼容性表由结构化数据生成.如果你想对数据做出贡献,请查看 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并发送给我们一个拉取请求.</div>
+
+<p>{{Compat("api.DOMImplementation.createDocument")}}</p>
+
+<h2 id="另请参见">另请参见</h2>
+
+<ul>
+ <li>归属它的 {{domxref("DOMImplementation")}} 接口.</li>
+</ul>