Basic knowledge about JAVASCRIPT objects and attributes

Source: Internet
Author: User
Tags natural logarithm number strings
JAVASCRIPT Object and attribute SCRIPT tag

Contains JavaScript code.

Syntax

Attribute

LANGUAGE-defined scripting LANGUAGE

SRC defines a URL to specify the file ending with. JS

Windows objects

The top-level object of each HTML document.

Attribute

Frames [] sublists array. Each sublists array is stored in the order defined in the source document.

Feames. length: Number of child partitions.

Self current window.

Parent window (the current window is a Child Window ).

Top-level window (the parent window of all visible windows ).

Status browser status window message.

DefaultStatus: the default message displayed in the browser status window when status is invalid.

Name: the internal name defined by the window opened by the window. open () method.


Method

Alert ("message") displays the "JavaScript Alert" dialog box containing the given message.

Confirm ("message") displays the "Confirm" dialog box containing the given message (there is an OK button and a Cancel button). If you click OK, return true; otherwise, return false.

The prompt ("message") displays a "prompt" dialog box. You are required to provide corresponding input based on the displayed message.

Open ("URL", "name") opens a new window with a specified name.

Close () close the current window.

Frame object


It is a subwindow of the entire browser window. Besides the status, defaultStatus, and name attributes, it has all the properties of the window object.


Location object


Contains information about the current URL.

Attribute

The entire URL string of href.

The protocol contains the first part of the URL, such as http:

Host contains a string containing the host name in the URL: port number, for example, // www.cenpok.net/server/

Hostname a string containing the host name in the URL. Such as a http://www.cenpok.net

Port contains the possible port number strings in the URL.

The part after "/" in the pathname URL. For example ~ List/index.htm

String after hash "#" (CGI parameter.

Search "? "# (CGI parameter.


Document Object


Objects that contain information about the current document.

Attribute

Title: The title of the current document. If not defined, it contains "Untitled ".

The full URL of the location document.

LastModified contains the last modification date of the document.

The URL of the referrer caller, that is, the URL from which the user is linked to the current page.

BgColor background color (# xxxxxx)

FgColor foreground text color.

The color of the linkColor hyperlink.

The hyperlink color accessed by vlinkColor.

AlinkColor activates the link color (when the mouse is not placed ).

Forms [] array of form objects in the document, which are stored in the defined order.

The number of form objects in the forms. length document.

Links [] is an array object corresponding to all HREF links in the document. Storage is defined in order.

The number of HREF chains in the links. length document.

Anchors [] anchors (...) array, which defines storage in order.

Anchors. length the number of anchors in the document.


Method

Write ("string") to highlight the string to the current window. (The string can contain HTML tags)

Writeln ("string") is similar to write (). It appends a carriage return character at the end, and only (

...
Or
...
) Takes effect.

Clear () clears the current window.

Close () close the current window.


Form object


Attribute

Name

The string value of the NAME attribute in.

Class value of the method attribute in METHOD, "0" = "GET", "1" = "POST ".

The string value of the action attribute in the ACTION.

Target table data submission target, which is consistent with the corresponding attribute in the tag.

The elements [index] elements attribute contains all elements in form.

Number of elements in the length table.


Method

Submit () submit the table.

The event processor onSubmit () user clicks a defined button to submit the code that runs when the form is submitted.


Text and textarea objects

Attribute

The string value of the name NAME attribute.

The string value of the value Field.

The initial string value of the defaultValue field.


Method

Focus () sets the object input focus.

Blur () removes the input focus from the object.

Select () the input area of the selected object.


Event Processor

OnFocus is executed when the input focus enters.

OnBlur is executed when the domain loses focus.

OnSelect is scheduled to run when some text in the field is selected.

OnChange is executed when the domain loses focus and the domain value changes from the onFocus execution.

Check box object


Attribute

The string value of the name NAME attribute.

The string value of the value Check box. If it is set, it is "on"; otherwise, it is "off ".

A boolean value of the checked check box. If it is set, it is true; otherwise, it is false.

DefaultChecked indicates the Boolean value of the (CHECKED) attribute (default state ).


Method

Click () Select the check box and make it "on ".


Event Processor

OnClick: it is executed when the user clicks Checkbox.


Radio button (radio) object


Attribute

The string value of the name NAME attribute.

The number of radio buttons in the length radio object.

The string value of the VALUE property.

Boolean value of checked. Press true. Otherwise, the value is false.

DefaultChecked indicates the Boolean value of the CHECKED attribute value.


Method

Click () Select a single button.


Event Processor

OnClick: scheduled to run when the single-choice button is selected.

Select object

Attribute

The number of objects in the length select object.

Name is the internal NAME of the select object defined by name = attribute.

The subscript of the currently selected option in the selectedIndex select object.

Options this attribute corresponds to the content marked when the select object is defined in HTML. It has the following attributes:

Text string marked by text.

Value of the VALUE Attribute. When the Submit button is pressed, the value is submitted.

DefaultSelected reflects the Boolean value of the marked SELECTED attribute.

The Boolean value that indicates the current selection status of the option.


Event Processor

OnFocus is executed when the input focus enters the domain.

OnBlur is executed when the domain loses the input focus.

OnChange: When the domain loses focus and the value of the domain changes compared to the onFocus execution, onChange is executed.


Button Object


There are three types of buttons in the table, which are defined by the TYPE attribute in the tag:

. Submit (type = "SUBMIT ")

. Reset (type = "RESET ")

. Custom (type = "BUTTON ")

All button objects have the following components:

Attribute

The string value of the VALUE property.

The string value of the name NAME attribute.


Method

Click () select button


Event Processor

OnClick: Execute when the button is clicked.


Submit and reset objects


Attribute

Value VALUE = attribute content.

Name NAME = attribute content.


Method

Click () select button


Event Processor

OnClick: Execute when the button is clicked.


Password object


Attribute

DefaultValue VALUE = attribute content.

Name NAME = attribute content.

Value currently enters data in the password field.


Method

Focus () brings the focus to the password field.

Blur removes the focus from the password field.

Select () select the current data in the password field for modification.


Navigator object


This object is used to determine the Navigator version used for user access.

Attribute

AppCodeName: "codename" relative to the user's browser"

The actual name of the appName relative to the user's browser.

The version of appVersion relative to the user's browser.

UserAgent this attribute reflects all information about the user's browser.

String object


The string object provides many methods for operating the string content.


Attribute

Length: the number of characters in the string.


Method

Big (), blink (), bold (), fixed (), italics (), small (), sub (), strike (), sup (), fontColor (color), fontSize (size)

The above method adds the corresponding HTML tag for the string.

CharAt (index) returns the character at index in the string.

IndexOf (searchValue, [fromIndex]) This method searches for the first searchValue in the string. If fromIndex is specified

The position in the string to start searching. When the searchValue is found, the position of the first character in the string is returned.

LastIndexOf (searchValue, [fromIndex]) Searches the searchValue forward from the end of the string and reports the First Instance found.

Substring (indexA, indexB) obtains the substring from indexA to indexB.

ToLowerCase (), toUpperCase () converts all characters in the string to uppercase and lowercase.


Date object


To use the Date object, you must first create a Date instance:

Variable name = new Date ();

Method

GetDay (), getDate (), getHours (), getMinutes (), getMonth (), getSeconds (), getTime (),

GetTimeZoneOffset (), getYear ()

And setDay ......

ToGMTString () returns the current time in GMT format. (Sun, 12 Feb 1999 14:19:22 GMT)

ToLocaleString returns the current time in locale Format. (03/11/99 14:19:22)

Parse (date) converts a normal date string into a haoss format, and then sets a parameter for setTime.


Math object


Attribute

LN10 (natural logarithm of 10)

PI (1415926 ...)

SQRT1_2 (square root of 1/2)

Method

Abs (x) returns the absolute value of x.

Acos (x) returns the arc cosine value of x.

Asin (x) returns the arc sin value of x.

Atan (x) returns the arc tangent value of x.

Ceil (x) returns the smallest integer greater than or equal to x.

Cos (x) returns the cosine value of x.

Exp (x) returns the x power of e.

Floor (x) returns the largest integer less than or equal to x.

Log (x) returns x's

Max (x, y) returns values in x, y.

Min (x, y) returns a small value in x and y.

Pow (x, y) returns the yth power of x.

Round (x) to the nearest integer (rounded off if it is less than or equal to 0.5 decimal places)

Sin (x) returns the sin value of x.

Sqrt (x) returns the square root of x.

Tan (x) returns the tangent value of x.

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.