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 July 2015.
io error: No such file or directory (os error 2) (/home/runner/work/yari/yari/mdn/translated-content/files/pt-br/web/api/domimplementation/index.md)
O método DOMImplementation.createDocument()
cria e retorna um XMLDocument
.
Sintaxe
doc = document.implementation.createDocument(namespaceURI, qualifiedNameStr, documentType);
Parâmetros
- namespaceURI
-
É um
DOMString
contendo a URI do namespace do documento que será criado, ounull
se o documento não pertencer a nenhum. - 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 Optional
-
Is the
DocumentType
of the document to be created. It defaults tonull
.
Example
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 Standard # ref-for-dom-domimplementation-createdocument② |
Compatibilidade com navegadores
BCD tables only load in the browser
See also
- The
DOMImplementation
interface it belongs to.