Javascript examples for DOM:Document doctype
The doctype property returns the doctype of the HTML document, as a DocumentType object.
The DocumentType object has a name property, which returns the name of the doctype.
If the document has no doctype specified, the return value is null.
The document's doctype, as a DocumentType object
The following code shows how to get the doctype name of an HTML document:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">display the doctype name of the document</button> <p id="demo"></p> <script> function myFunction() {/* w ww .j a va 2 s.com*/ var x = document.doctype.name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>