JavaScript Getting Started 6 --------------- Jilin University CAE Campus Fee Forum Faith 2008

xiaoxiao2021-03-06  50

Use the browser's internal object system to interact with the HTML document. Its role is to package related elements to provide programming designers, reducing programmers, and improving the ability to design web pages.

First, the browser object level and its main role

In addition to the previously mentioned document Document objects, the Navigator browser also provides Window Objects, and History and Location objects.

Browser Object (Navigator)

Provide information about the browser

Window Object (Windows)

The Window object is at the top of the object level, which provides methods and properties that process the Navigator window.

Location object (location)

The Location object provides methods and properties that work with the current URL, which is a static object.

Historical object (History)

The History object provides information about historical list.

Document Object (Document)

The Document object contains objects working with document elements (Elements), which encapsulates these elements for programmers.

Programmakers use these objects to control and process the events in the WWW browser environment. It provides a very rich internal method and attribute in JavaScript, thereby reducing the work of programmers and improving programming efficiency. This is exactly based on object and object-oriented differences. In these object systems, document objects are very important, it is located at the lowest layer, but is a key role in our implementation of Web page information interaction. Therefore it is the core part of the object system.

Second, document object function and its role

In the Navigator browser, the Document document object is the core is the most important. See Figure 6-1.

Links Anchor Form Method Prop

Link Object Anchor Object Form Object Method Object

Figure 6-1 Document object

As can be seen from Figure 6-1, the main role of the Document object is to package these basic elements (such as Links, Anchor, etc.) to provide programmers. From another perspective, the Document object is composed of attributes and methods.

1, three main objects in Document

In Document, there are three most important objects such as Links, Anchor, Form:

(1) Anchor Anchor Object:

The Anchor object refers to the object that is

The onChNGE event is used (excited when the form content changes). The first use of the form name identifies my, the second use of the form array forMs []. Its effect is consistent.

2. Attribute attribute in the document object

The Attribute property in the Document object is primarily used to control the format of the color and the Document title, the document original file, and the date of the document title, the date of the document title, the document. The main meanings of this part of the elements are as follows:

(1) Link color: alinkcolor

This element is primarily used, when elects a link, the color of the link object itself is specified by AlinkColo R.

(2) Link color: LinkColor

When the user uses after the Text String

(3) Viewed colors after viewing: VLINKCOLOR

This property is indicated by browsing to store the browsed link color.

(4) Background color: bgcolor

This element contains the color of the document background.

(5) Prospect Color: fgcolor

This element contains the foreground color of the text in the HTML document.

3. Basic elements of document objects

(1) Form properties:

Form Properties is a set of objects that correspond to ... in the HTML document in the HTML document, specified by Length. Reflect the number of forms created in this document via Document.Forms.Length.

(2) Anchor properties: Anchors

In this property, all the statement identifiers of all the labeled name = ... containing the HTML document. The number of all anchors is saved in Document.Anchors.Length.

(3) Link Properties: LINKS

The link attribute refers to the number specified by href = ... in the document, and the number of links is stored in Document.Links.Length.

Third, example

Example 1: Let's explain the integrated application of document objects through an example. The output results are shown in Figure 6-2.

TEST6_2.HTM

Please enter the data:

Link to the first text
link to the second text < / a>

Link to the third text

First anchor point

Second Anchor Point

third anchor point