JavaScript Object Reference (3)
The history Object
The history object allows a script to work with the browser's history list in JavaScript. For security and privacy reasons, the actual content of the list is not reflected into JavaScript.
Properties
- length
- An integer representing the number of items on the history list.
Methods
- back()
- Goes back to the previous document in the history list.
- forward()
- Goes forward to the next document in the history list.
- go(location)
- Goes to the document in the history list specified by location. location can be a string or integer value. If it is a string it represents all or part of a URL in the history list. If it is an integer, location represents the relative position of the document on the history list. As an integer, location can be positive or negative.
The link object
The link object reflects a hypertext link in the body of a document.
Properties
- target
- A string value containing the name of the window or frame specified in the TARGET attribute.
Event Handlers
- onClick
- Specifies JavaScript code to execute when the link is clicked.
- onMouseOver
- Specifies JavaScript code to execute when the mouse is over the hypertext link.
The location Object
The location object reflects information about the current URL.
Properties
- hash
- A string value containing the anchor name in the URL.
- host
- A string value containing the hostname and port number from the URL.
- hostname
- A string value containing the domain name (or numerical IP address) from the URL.
- href
- A string value containing the entire URL.
- pathname
- A string value specifying the path portion of the URL.
- port
- A string value containing the port number from the URL.
- protocol
- A string value containing the protocol from the URL (including the colon, but not the slashes).
- search
- A string value containing any information passed to a GET request (i.e. any information after the question mark).
The Math Object
The Math object provides properties and methods for advanced mathematical calculations.
Properties
- E
- The value of Euler's constant (roughly 2.718) used as the base for natural logarithms.
- LN10
- The value of the natural logarithm of 10 (roughly 2.302).
- LN2
- The value of the natural logarithm of 2 (roughly 0.693).
- PI
- The value of PI used in calculating the circumference and the area of circles (roughly 3.1415).
- SQRT1_2
- The value of the square root of one-half (roughly 0.707).
- SQRT2
- The value of the square root of two (roughly 1.414).
Methods
- abs(number)
- Returns the absolute value of number. The absolute value is the value of a number with it's sign ignored so abs(4) and abs(-4) both return 4.
- acos(number)
- Returns the arc cosine of number in radians.
- asin(number)
- Returns the arc sine of number in radians.
- atan(number)
- Returns the arc tangent of number in radians.
- ceil(number)
- Returns the next integer greater than number; in other words, rounds up to the next integer.
- cos(number)
- Returns the cosine of number where number represents an angle in radians.
- exp(number)
- Returns the value of E to the power of number.
- floor(number)
- Returns the next integer less than number; in other words, rounds down to the nearest integer.
- log(number)
- Returns the natural logarithm of number.
- max(number1,number2)
- Returns the greater of number1 and number2.
- min(number1,number2)
- Returns the smaller of number1 and number2.
- pow(number1,number2)
- Returns the value of number1 to the power of number2.
- random()
- Returns a random number between zero and one.
- round(number)
- Returns the closest integer to number in other words rounds to the closest integer.
- sin(number)
- Returns the sine of number where number represents an angle in radians.
- sqrt(number)
- Returns the square root of number.
- tan(number)
- Returns the tangent of number where number represents an angle in radians.
The navigator object
The navigator object reflects information about the browser being used.
Properties
- appCodeName
- A string value containing the code name of the client.
- appName
- A string value containing the name of the client.
- appVersion
- A string value containing the version information for the client.
- userAgent
- A string containing the complete value of the user-agent header sent in the HTTP request. This contains all the information in appCodeName and appVersion. For instance,
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)
Previous | Contents | Next
|