Document doctype Property - Javascript DOM

Javascript examples for DOM:Document doctype

Description

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.

Return Value

The document's doctype, as a DocumentType object

The following code shows how to get the doctype name of an HTML document:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials