Getting started with JavaScript (10) understanding other object_basic knowledge

Source: Internet
Author: User
You need to understand the elements that require better control of html. You can check it if necessary. Anchors []; links []; Link connection object
Usage: document. anchors [[X] ]; Document. links [[X] ];;
Document. anchors is an array that contains all the anchors (including the name attribute tags) in the document. A subscript is defined for each anchors starting from 0 in the order in the document.
Document. links is also an array that contains all the connection tags in the document (including the href attribute tags and Mark in the mark segment), according to the order in the document, from 0 to define a subscript for each connection mark.
If a tag has both the name and href attributes, it is both an Anchor object and a Link object.
In IE, if the "id ="... "attribute is added to the tag, this object is assigned an ID. To call this object, you only need to use" . 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; hrefIt 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 tag.
Event
Onclick; onmouseover; onmouseout; onmousedown; onmouseup
Applets [] Java Applet objectIt is an array containing 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 objectIt is an array containing all the plug-ins in the document ( Mark ). Because of the differences in each plug-in, each Embed object also has different attributes and methods.
Forms []; Form objectDocument. forms [] is an array that contains all forms in the document ( ). To reference a single form, you can use document. forms [x], but in general, people will do this:Add the "name ="... "attribute to the tag, then directly use" document. <表单名> .
Form Object Attributes
NameThe name of the returned form, that isAttribute.
Action
Return/set the form submission address, that isAttribute.
MethodReturns/sets the form submission method, that isAttribute.
TargetReturn/set the window returned after the form is submitted, that isAttribute.
EncodingReturns/sets the encoding method of the content submitted by the form, that isAttribute.
LengthReturns the number of elements contained in the form.
Method
Reset ()Reset 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.
Button ObjectBy . Reference a Button object. You can use <文档对象> . <表单对象> . <按钮名称> ". <按钮名称> In The value of the "name ="... "attribute in the tag. This method can be used to reference any form element.
Attribute
NameReturn/Set The name of the specified element.
Value
Return/Set The value of the specified element.
FormReturns the form object that contains this element.
Method
Blur ()Move the focus from the object.
Focus ()Focus on the object.
Click ()Simulate Mouse clicking on this object.
Event
Onclick; onmousedown; onmouseup
Checkbox check box objectBy .
Attribute
NameReturn/Set The name of the specified element.
Value
Return/Set The value of the specified element.
FormReturns the form object that contains this element.
CheckedReturn/set whether the check box object is selected. This is a Boolean value.
DefaultCheckedReturn/set whether the check box object is selected by default. This is a Boolean value.
Method
Blur ()Move the focus from the object.
Focus ()
Focus on the object.
Click ()Simulate Mouse clicking on this object.
Event
Onclick
Elements []; Element form Element Object <表单对象> . Elements is an array that contains all objects in the form. Generally, we do not need this array, but directly reference each specific object.
Hidden objectBy .
Attribute
NameReturn/Set The name of the specified element.
Value
Return/Set The value of the specified element.
Form
Returns the form object that contains this element.
Password and Password input area objectBy .
Attribute
NameReturn/Set The name of the specified element.
Value
Returns/sets the current value of the password input area.
DefaultValue
Return The default value.
Form
Returns the form object that contains this element.
Method
Blur ()Move the focus from the object.
Focus ()
Focus on the object.
Select ()Select all text in the password input area.
Event
Onchange
Radio single-choice domain objectBy . 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
NameReturn/Set The name of the specified element.
Value
Return/Set The value of the specified element.
Form
Returns the form object that contains 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 ()Move the focus from the object.
Focus ()
Focus on the object.
Click ()
Simulate Mouse clicking on this object.
Event
Onclick
Reset button objectBy . 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.
Select area (drop-down menu, list) objectBy .AttributeNameReturn/Set The name of the specified element.
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 that contains this element.
Method
Blur ()Move the focus from the object.
Focus ()
Focus on the object.
Event
Onchange
Options []; Option select item objectOptions [] is an array that contains Option objects under the same Select object. The Option object consists of ".Options [] attributes of an arrayLength; selectedIndexThe property is the same as that of the Select object.Attributes of a single Option objectTextReturns/specifies the text displayed by the Option objectValueReturns/specifies the value of the Option object, and.IndexReturns 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.SelectedReturns/specifies whether the object is selected. By specifying true or false, You can dynamically change the selected item.DefaultSelectedReturns whether the object is selected by default. True/false.Submit button objectBy . 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.
Text box objectBy . 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.
Textarea multi-line text input area objectBy . 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 []; Image objectDocument. 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, an image is defined in the format of "", you can use "document. images ['... ']' to reference the image. In IE, if an image contains the ID attribute, that is, an image is defined in the format of "", you can directly use" To reference the image.
Attributes of a single Image object
Name; src; lowsrc; width; height; vspace; hspace; borderThese 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 ( <图片地址字符串> );
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.

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.