What is the Document object in HTML? An article that gives you an idea of the document object

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.