DOMImplementation.createDocument()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since julho de 2015.
O método DOMImplementation.createDocument() cria e retorna um XMLDocument.
Sintaxe
doc = document.implementation.createDocument(namespaceURI, qualifiedNameStr, documentType);
Parâmetros
- namespaceURI
-
É um
DOMStringcontendo a URI do namespace do documento que será criado, ounullse o documento não pertencer a nenhum. - qualifiedNameStr
-
Is a
DOMStringcontaining the qualified name, that is an optional prefix and colon plus the local root element name, of the document to be created. - documentType Optional
-
Is the
DocumentTypeof the document to be created. It defaults tonull.
Example
js
var doc = document.implementation.createDocument(
"https://www.w3.org/1999/xhtml",
"html",
null,
);
var body = document.createElementNS("https://www.w3.org/1999/xhtml", "body");
body.setAttribute("id", "abc");
doc.documentElement.appendChild(body);
alert(doc.getElementById("abc")); // [object HTMLBodyElement]
Especificações
| Specification |
|---|
| DOM> # ref-for-dom-domimplementation-createdocument②> |
Compatibilidade com navegadores
Loading…
See also
- The
DOMImplementationinterface it belongs to.