DOMImplementation.createDocument()
method creates and returns an
XMLDocument
.
var doc = document.implementation.createDocument(namespaceURI, qualifiedNameStr, documentType);
namespaceURI
DOMString
containing the namespace URI of the document to be created, or
null
if the document doesn't belong to one.
qualifiedNameStr
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
可选
Is the
DocumentType
of the document to be created. It defaults to
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]
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM
The definition of 'DOMImplementation.createDocument' in that specification. |
实时标准 |
Modified the return type of
createDocument()
from
Document
to
XMLDocument
.
The third argument of
createDocument()
,
doctype
, is now optional and default to
null
.
|
|
DOM (文档对象模型) 3 级核心规范
The definition of 'DOMImplementation.createDocument' in that specification. |
过时 | 无变化自 DOM (文档对象模型) 级别 2 核心规范 |
|
DOM (文档对象模型) 级别 2 核心规范
The definition of 'DOMImplementation.createDocument' in that specification. |
过时 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
createDocument
|
Chrome Yes | Edge 12 | Firefox Yes | IE 9 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
DOMImplementation
interface it belongs to.
DOMImplementation
createDocument()
createDocumentType()
createHTMLDocument()
hasFeature()
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument