This article mainly describes the HTML Document object interpretation, as well as the use of HTML Document object parsing, then let's look at this article together
Let's start by introducing the Document object in HTML:
The Document object represents the document in the browser window, which is a child of the Window object, and because the Window object is the default object in the DOM object model, the methods and sub-objects in the Window object do not need to be referenced by using window.
The Document object provides access to any HTML markup contained in an HTML document and can dynamically change the content in the HTML markup.
Examples include forms, images, tables, hyperlinks, and so on.
Then look at the collection of document objects in HTML:
Take a look at the description of the Document object in HTML on the Web:
The HTMLDocument interface extends the DOM document interface, defining HTML-specific properties and methods.
Many properties and methods are Htmlcollection objects (which are actually read-only groups that can be indexed with arrays or names), where references to anchors, forms, links, and other scriptable elements are saved.
These collection properties are derived from the level 0 dom. They have been replaced by document.getElementsByTagName (), but they are still often used because they are convenient.
The Write () method is worth noting that when a document is loaded and parsed, it allows a script to insert dynamically generated content into the document.
Note that in the Level 1 DOM, HTMLDocument defines a very useful method named getElementById (). In the Level 2 DOM, the method has been transferred to the document interface, which is now inherited by HTMLDocument rather than defined by it.
Next, let's use an example of an HTML Document object:
The Document object is used to check the title of the file and display the caption in a message box if it is not empty. if (document.title!= "") alert (titled "+document.title") The following example shows an event handle function that displays the current position of the mouse on the status bar of the browser, resulting in a position relative to the upper-left corner of the document.
The above is the introduction of the HTML Document object, and the use of examples, so that you more clearly understand the HTML document object, what questions can be asked below.