The DocumentType type is not commonly used in WEB browsers. Firefox, Safari, Opera and Chrome browsers support the DocumentType type, but the IE browser does not support the DocumentType type. DocumentType contains information related to the document doctype. It has the following characteristics:
The value of nodeType is 10.
The value of nodeName is the name of doctype.
The value of nodeValue is null.
parentNode is Document.
It has no child nodes.
In DOM1 level, DocumentType objects cannot be created dynamically, but can only be created by parsing the document code. Browsers that support it will save the DocumentType object in document.doctype.
DOM1 level depicts three attributes of the DocumentType object: name, entities and notations. Among them, the name attribute represents the name of the document type; the entities attribute is the NamedNodeMap object of the entity described by the document type; the notations attribute is the NamedNodeMap object of the symbol described by the document type.
Usually documents in browsers use is an HTML or XHTML document type, so entities and notations are both empty lists (the items in the list come from the inline document type declaration). The name attribute stores the name of the document type, which is the text content that appears after
The following example is an example of a strict HTML4.01 document type declaration:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
The name attribute of DocumentType saves "HTML", which can be viewed through the console:
console.info(document.doctype.name);
IE does not support DocumentType, so the value of document.doctype will always be null. However, Internet Explorer incorrectly interprets the document type as a comment and creates a comment node for it.
The above is the content of the JavaScript Document Object Model-DocumentType type. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!