Other Objects in JavaScript

Source: Internet
Author: User

Anchors []; links []; Link connection object
Usage: document. anchors [[x]; document. links [[x]; <anchorId >;< linkId>
Document. anchors is an array that contains all the anchors (including the <a> tag of the name attribute) in the document, in the order in the document, a subscript is defined for each anchor tag starting from 0.
Document. links is also an array that contains all the connection tags in the document (including the <a> mark of the href attribute and the <area> mark in the <map> MARK segment ), in the order in the document, a subscript is defined for each connection mark starting from 0.
If a <a> tag has both the name and href attributes, it is both an Anchor object and a Link object.
In IE, if you add "id = "... "" attribute, the <a> object is assigned an ID. To call this object, you only need to use "<id>. Many document parts can use this method to assign IDs, but note that there cannot be two identical IDs.
Anchors and links are used as arrays and have the attributes and methods of arrays. No attribute exists for a single Anchor object. For details about attributes of a single Link object, see.

Attribute
Protocol; hostname; port; host; pathname; hash; search; href is the same as the location object.
Target Returns/specifies the target window (string) of the connection, which is the same as the target attribute in the <a> mark.
Event
Onclick; onmouseover; onmouseout; onmousedown; onmouseup

Applets [] Java Applet object it is an array that contains all the Applet objects in the document (Java Applet ). An array has attributes and methods. For the attributes and methods of a single Applet object, I reference a sentence: "The Applet object inherits all the common attributes and methods of the Java Applet ." The Applet object inherits all public properties of the Java applet. /The Applet object inherits all public methodss of the Java applet .) I hate Java applets, so I am not interested in any "public" or "private" issues, so I will not discuss them.
Embeds [] plug-in object is an array that contains all the plug-ins (<embed> tags) in the document ). Because of the differences in each plug-in, each Embed object also has different attributes and methods.
Forms []; Form object document. forms [] is an array containing all forms in the document (<form> ). To reference a single form, you can use document. forms [x], but in general, people will do this: Add "name =" in the <form> tag "... "" attribute, then directly use "document. <form name> "can be referenced.

Form Object Attributes
Name: return the form name, that is, the <form name = "..."> attribute.
Action returns/sets the form submission address, that is, the <form action = "..."> attribute.
Method returns/sets the form submission method, that is, the <form method = "..."> attribute.
Target Returns/sets the window returned after the form is submitted, that is, the <form target = "..."> attribute.
Encoding returns/sets the encoding method of the content submitted by the form, that is, the <form enctype = "..."> attribute.
Length returns the number of elements contained in the form.
Method
Reset () resets the form. This is the same as pressing the reset button.
Submit () submit the form. This is the same as pressing the submit button.
Event
Onreset; onsubmit

The following elements from "Button" to "Textarea" are form Element objects.
The Button object is specified by <input type = "button">. To reference a Button object, you can use "<Document Object>. <form Object>. <Button name> ". <Button name> refers to the value of the "name ="... "attribute in the <input> tag. This method can be used to reference any form element.

Attribute
<Input name = "..."> specifies the element name.
Value Returns/sets the value of the specified element with <input value = "...">.
Form returns the form object containing this element.
Method
Blur () removes the focus from the object.
Focus () gets the focus of the object.
Click.
Event
Onclick; onmousedown; onmouseup

The Checkbox check box object is specified by <input type = "checkbox">.

Attribute
<Input name = "..."> specifies the element name.
Value Returns/sets the value of the specified element with <input value = "...">.
Form returns the form object containing this element.
Checked returns/sets whether the check box object is selected. This is a Boolean value.
DefaultChecked returns/sets whether the check box object is selected by default. This is a Boolean value.
Method
Blur () removes the focus from the object.
Focus () gets the focus of the object.
Click.
Event
Onclick

Elements []; Element form Element Object <form Object>. elements is an array that contains all objects of the form. Generally, we do not need this array, but directly reference each specific object.
The Hidden object is specified by <input type = "hidden">.

Attribute
<Input name = "..."> specifies the element name.
Value Returns/sets the value of the specified element with <input value = "...">.
Form returns the form object containing this element.

The Password field object is specified by <input type = "password">.

Attribute
<Input name = "..."> specifies the element name.
Return/set the current value of the password input area.
DefaultValue is returned with the default value specified by <input value = "...">.
Form returns the form object containing this element.
Method
Blur () removes the focus from the object.
Focus () gets the focus of the object.
Select () select all text in the password input area.
Event
Onchange

The Radio radio Field object is specified by <input type = "Radio">. A group of Radio objects have a common name (name attribute). In this way, document. formName. radioName becomes an array. To access a single Radio object, use: document. formName. radioName [x].

Properties of a single Radio object
<Input name = "..."> specifies the element name.
Value Returns/sets the value of the specified element with <input value = "...">.
Form returns the form object containing this element.
Checked returns/sets whether the single-choice domain object is selected. This is a Boolean value.
DefaultChecked returns/sets whether the object is selected by default. This is a Boolean value.
Method
Blur () removes the focus from the object.
Focus () gets the focus of the object.
Click.
Event
Onclick

The Reset reset button object is specified by <input type = "Reset">. Because Reset is also a Button, attributes and methods of the Button object are also available. For the "onclick" event, it is generally replaced by the onreset of the Form object.
The Select select area (drop-down menu, list) object is specified by "<Select>.

Attribute
<Input name = "..."> specifies the element name.
Length returns the number of options in the Select object.
SelectedIndex returns the subscript of the selected option. This subscript is the position of this option in the options [] array. If the Select object allows multiple selections, the subscript of the first selected option is returned.
Form returns the form object containing this element.
Method
Blur () removes the focus from the object.
Focus () gets the focus of the object.
Event
Onchange

Options []; Option Selection item object options [] is an array that contains the Option object under the same Select object. The Option object is specified by "<options>" under "<select>.

Options [] attributes of an array
Length; selectedIndex has the same attributes as the Select object.
Attributes of a single Option object
Text return/Specify the text displayed by the Option object
Value Returns/specifies the value of the Option object, which is consistent with <options value = "...">.
Index returns the subscript of the Option object. There is nothing to say about this, because to specify a specific Option object, you must first know the subscript of this object. This attribute seems useless.
Selected returns/specifies whether the object is selected. By specifying true or false, You can dynamically change the selected item.
DefaultSelected returns whether the object is selected by default. True/false.

The Submit button object is specified by <input type = "submit">. Because Submit is also a Button, attributes and methods of the Button object are also available. For the "onclick" event, it is generally replaced by the onsubmit of the Form object.
The Text text box object is specified by <input type = "Text">. The Password object is also a type of Text object. Therefore, all attributes, methods, and events of the Password object are included in the Text object.
The object in the multi-line text input area of Textarea is specified by <textarea>. All attributes, methods, and events of the Textarea object are the same as those of the Text object, that is, they are the same as those of the Password object.
Images []; The Image object document. images [] is an array that contains all the images in the document ( ). To reference a single image, use document. images [x]. If an image contains the "name" attribute, that is, "
Attributes of a single Image object
These attributes are the same as those in the tag. In Netscape, except for the src attribute, other attributes (almost all) cannot be changed. Even if the src attribute is changed, the effect cannot be displayed in the document. The most useful of these attributes is src. by assigning values to the src attribute, you can change the image in real time.
Event
Onclick
Image objects not displayed in the document
The Image object not displayed in the document is defined using the var statement:

Var myImage = new Image (); or
Var myImage = new Image (<Image address string> );

Then you can treat the myImage variable like an Image object. However, since it is not displayed in the document, the following attributes: lowsrc, width, height, vspace, heat ace, and border are useless. Generally, only one such object is used: preload ). When the object's src attribute is assigned a value, reading the entire document and running JavaScript are paused, allowing the browser to read the image intently. After pre-reading the image, the image Copy will be available in the browser cache. when you really want to put the image in the document, the image will be immediately displayed. Currently, some images are often connected on webpages. When you point to it, the images are replaced with another one. They are pre-read images first.
JavaScript example of preread Images

Var imagePreload = new Image ();
ImagePreload. src = '001.gif ';
ImagePreload. src = '002.gif ';
ImagePreload. src = '003.gif ';

The preceding example is suitable for prereading a small number of images.

Function imagePreload (){
Var imgPreload = new Image ();
For (I = 0; I <arguments. length; I ++ ){
ImgPreload. src = arguments [I];
}
}
ImagePreload('001.gif ', '002.gif', '003.gif ', '004.gif', '005.gif ');

The above example is suitable for prereading a large number of images.

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.