Home > Web Front-end > JS Tutorial > JavaScript Document Object Model-DocumentType type

JavaScript Document Object Model-DocumentType type

黄舟
Release: 2017-01-20 14:45:02
Original
1705 people have browsed it

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">
Copy after login

The name attribute of DocumentType saves "HTML", which can be viewed through the console:

console.info(document.doctype.name);
Copy after login

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 (m.sbmmt.com)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template