Document.doctype
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.
Devuelve la Declaración de tipo de documento (Document Type Declaration (DTD)), asociada al documento actual. El objeto devuelto implementa la interfaz DocumentType
. Utilice DOMImplementation.createDocumentType()
para crear un DocumentType
.
Sintaxis
doctype = document.doctype;
doctype
es una propiedad de sólo lectura.
Ejemplo
var doctypeObj = document.doctype;
console.log(
"doctypeObj.name: " +
doctypeObj.name +
"\n" +
"doctypeObj.internalSubset: " +
doctypeObj.internalSubset +
"\n" +
"doctypeObj.publicId: " +
doctypeObj.publicId +
"\n" +
"doctypeObj.systemId: " +
doctypeObj.systemId,
);
Notas
La propiedad devuelve null
si no hay DTD asociada al documento actual.
El nivel 2 de DOM no soporta la edición de la declaración de tipo de documento.
Especificaciones
Specification |
---|
DOM # ref-for-dom-document-doctype① |
Compatibilidad del Navegador
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
doctype |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support