Table of Contents
欢迎!
Home Web Front-end HTML Tutorial What is the document object in html? An article to let you understand the document object

What is the document object in html? An article to let you understand the document object

Sep 01, 2018 pm 01:59 PM
document html

This article mainly introduces the explanation of the HTML document object, as well as the analysis of usage examples of the HTML document object. Next, let us look at this article together.

First of all, let’s Let’s introduce the document object in HTML:

The document object (document) represents the document in the browser window. This object is a sub-object of the window object, because the window object is the default in the DOM object model. Object, so methods and sub-objects in the window object do not need to be referenced using window.

You can access any HTML tag contained in the HTML document through the document object and dynamically change the content in the HTML tag.

For example, forms, images, tables, hyperlinks, etc.

Let’s take a look at the collection of Document objects in HTML:

What is the document object in html? An article to let you understand the document objectLet’s take a look at the online description of document objects in HTML:

HTMLDocument interface extends the DOM Document interface and defines HTML-specific properties and methods.

Many properties and methods are HTMLCollection objects (actually read-only arrays that can be indexed by array or name), which hold references to anchors, forms, links, and other scriptable elements.

These collection attributes are derived from level 0 DOM. They have been superseded by Document.getElementsByTagName(), but are still often used because they are convenient.

The write() method is worth noting because it allows a script to insert dynamically generated content into the document while the document is loading and parsing.

Note that in the level 1 DOM, HTMLDocument defines a very useful method called getElementById(). In the level 2 DOM, this method has been moved to the Document interface, and it is now inherited by HTMLDocument rather than defined by it.

Next, give an example of using the HTML document object:

1

2

3

4

5

6

7

8

9

10

11

12

13

<HTML>

<HEAD>

<TITLE>PHP中文网</TITLE>

<SCRIPT LANGUAGE="JScript">function reportMove()

{ window.status = "X=" + window.event.x + " Y=" + window.event.y;

}

</SCRIPT>

</head>

<BODY onmousemove="reportMove()">

<h1 id="欢迎">欢迎!</h1>

</BODY>

</HTML>

上面的例子使

Copy after login

Use the document object to check the document title and display the title in the message box (if it is not empty ). if(document.title!="")alert("title is " document.title) The following example demonstrates an event handler function that displays the current position of the mouse on the browser's status bar, relative to the upper left corner of the document.

The above is the introduction and usage examples of this article about the HTML document object, so that you can have a clearer understanding of the HTML document object. If you have any questions, you can ask below.

【Editor's Recommendation】

How to set the font size of the font tag in html? Introduction to the usage of html font tag attribute

What is the code for adding images in HTML? How to add image path correctly in html?

The above is the detailed content of What is the document object in html? An article to let you understand the document object. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

GTA 6 document gives a detailed overview of all leaks GTA 6 document gives a detailed overview of all leaks Sep 08, 2024 am 06:37 AM

On September 3, version 1.5 of the Grand Theft Auto VI document which provides a detailed overview of everything that is known about the game to date. The updated version of the document was announced in a trailer published on X (formerly Twitter).??

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

See all articles