doctype
Summary
Gets an object that represents the document type declaration that is associated with the current document.
Property of dom/Documentdom/Document
Syntax
Note: This property is read-only.
var doctype = document.doctype;
Return Value
Returns an object of type DOM NodeDOM Node
The DocumentType instance object of the document.
Examples
This example retrieves the document’s DOCTYPE and displays some of its available components.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<script type="text/javascript">
function getDocType () {
if (document.doctype) {
var dtinfo = "DOCTYPE name: " + document.doctype.name;
dtinfo += "\nDOCTYPE publicId: " + document.doctype.publicId;
dtinfo += "\nDOCTYPE systemId: " + document.doctype.systemId;
alert(dtinfo);
}
else {
alert ("Your browser does not support this example");
}
}
</script>
</head>
<body>
<button onclick="getDocType();">View DOCTYPE information</button>
</body>
</html>
Related specifications
- DOM Level 3 Core
- Recommendation
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]