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.
Document
接口的 doctype
只读属性表示与当前文档关联的文档类型声明(DTD)的 DocumentType
对象。
值
DocumentType
对象。
示例
js
const doctypeObj = document.doctype;
console.log(`doctypeObj.name: ${doctypeObj.name}`);
console.log(`doctypeObj.internalSubset: ${doctypeObj.internalSubset}`);
console.log(`doctypeObj.publicId: ${doctypeObj.publicId}`);
console.log(`doctypeObj.systemId: ${doctypeObj.systemId}`);
备注
如果当前文档没有关联 DTD,该属性将返回 null
。
DOM 第 2 级规范不支持编辑文档类型声明。
规范
Specification |
---|
DOM # ref-for-dom-document-doctype① |
浏览器兼容性
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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.