JavaScript获取文档类型声明 (DTD)|Document doctype 属性
定义与用法
doctype 属性可返回与文档相关的文档类型声明(Document Type Declaration)。
阅读更多文档类型对象的知识,请查看 文档类型对象参考手册.
提示: 如果文档没有指定文档类型,返回值为 null.
语法格式
document.doctype
示例代码
返回 HTML 文档的文档类型对象:
document.doctype;
浏览器支持
属性 | |||||
---|---|---|---|---|---|
doctype | Yes | Yes | Yes | Yes | Yes |
所有主要浏览器都支持 doctype 属性
提示: Internet Explorer 8 及 IE 更早版本显示HTML 和 XHTML文档时该属性返回 null ,但是支持 XML 文档.
技术细节
返回值: | 文档的文档类型, 作为一个 DocumentType 对象。 |
---|---|
DOM 版本 | Core Level 1 Document 对象 |