DOMImplementation.createDocument()

这篇翻译不完整。请帮忙从英语翻译这篇文章

DOMImplementation.createDocument()方法创建并返回一个 XMLDocument对象.

语法

doc = document.implementation.createDocument(namespaceURI, qualifiedNameStr, documentType);

参数

namespaceURI
被创建的DOMString 文档的namespaceURI 是namespaceURI ,如果文档不属于任何namespaceURI 就为null.
qualifiedNameStr
Is a DOMString containing the qualified name, that is an optional prefix and colon plus the local root element name, of the document to be created.
documentType 可选
文档的DocumentType. 默认为null.

例子

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]

规范

Specification Status Comment
DOM
DOMImplementation.createDocument
Living Standard Modified the return type of createDocument() from Document to XMLDocument.
The third argument of createDocument(), doctype, is now optional and default to null.
Document Object Model (DOM) Level 3 Core Specification
DOMImplementation.createDocument
Obsolete No change from Document Object Model (DOM) Level 2 Core Specification
Document Object Model (DOM) Level 2 Core Specification
DOMImplementation.createDocument
Obsolete Initial definition.

浏览器支持

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) 1.0 (1.7 or earlier) 9.0 (Yes) (Yes)
3rd argument of createDocument() optional (Yes) 未实现 26.0 (26.0) 未实现 (Yes) (Yes)
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)
3rd argument of createDocument() optional (Yes) 未实现 26.0 (26.0) 未实现 (Yes) (Yes)

See also

文档标签和贡献者

此页面的贡献者: Cribug8080
最后编辑者: Cribug8080,