The tan method returns a numeric value which represents the tangent of the angle.
例子
//Displays the value 0.9999999999999999
document.write("The tangent of pi/4 radians is " +
Math.tan(Math.PI/4))
//Displays the value 0
document.write("<P>The tangent of 0 radians is " +
Math.tan(0))
For form, a string specifying the name of the window that responses go to after a form has been submitted. For link, a string specifying the name of the window that displays the content of a clicked hypertext link.
语法
1. formName.target
2. links[index].target
formName is either the name of a form or an element in the forms array. index is an integer representing a link object.
NAME="textName" specifies the name of the text object. You can access this value using the name property. VALUE="textValue" specifies the initial value of the text object. You can access this value using the defaultValue property. SIZE=integer specifies the number of characters the text object can accommodate without scrolling.
textName is the value of the NAME attribute of a text object. formName is either the value of the NAME attribute of a form object or an element in the forms array. index is an integer representing a text object on a form. propertyName is one of the properties listed below. methodName is one of the methods listed below.
Example 1. The following example creates a text object that is 25 characters long. The text field appears immediately to the right of the words "Last name:". The text field is blank when the form loads.
Last name:
Example 2. The following example creates two text objects on a form. Each object has a default value. The city object has an onFocus event handler that selects all the text in the field when the user tabs to that field. The state object has an onChange event handler that forces the value to upper case.
A string specifying the text that follows an <OPTION> tag in a select object.
语法
selectName.options[index].text
selectName is either the value of the NAME attribute of a select object or an element in the elements array. index is an integer representing an option in a select object.
The text property initially reflects the text that follows an <OPTION> tag in a select object.
You can set the text property at any time; however, the following effects result:
The value of the property changes.
The text displayed by the option in the select object does not change.
Be careful if you change the text property. If you evaluate the property after you change it, the property contains the new value, not the value that is displayed onscreen.
例子
In the following example, the getChoice() function returns the value of the text property for the selected option. The for loop evaluates every option in the musicType select object. The if statement finds the option that is selected.
function getChoice() {
for (var i = 0; i < document.musicForm.musicType.length; i++) {
if (document.musicForm.musicType.options[i].selected == true) {
return document.musicForm.musicType.options[i].text
}
}
return null
}
The previous example assumes that the select object is similar to the following:
<SELECT NAME="musicType">
<OPTION SELECTED> R&B
<OPTION> Jazz
<OPTION> Blues
<OPTION> New Age
</SELECT>
NAME="textareaName" specifies the name of the textarea object. You can access this value using the name property. ROWS="integer" and COLS="integer" define the physical size of the displayed input field in numbers of characters. textToDisplay specifies the initial value of the textarea object. A textarea allows only ASCII text, and new lines are respected. You can access this value using the defaultValue property.
The WRAP attribute controls word wrapping inside the TEXTAREA. The value "off" is default and lines are sent exactly as typed. The value "virtual" wraps in the display but are sent exactly as typed. The value "physical" wraps in the display and sends new-lines at the wrap points as if new-lines had been entered.
To use a textarea object's properties and methods:
textareaName is the value of the NAME attribute of a textarea object. formName is either the value of the NAME attribute of a form object or an element in the forms array. index is an integer representing a textarea object on a form. propertyName is one of the properties listed below. methodName is one of the methods listed below.
A textarea object is a form element and must be defined within a <FORM> tag.
textarea objects can be updated (redrawn) dynamically by setting the value property (this.value).
To begin a new line in a textarea object, you can use a newline character. This character varies from platform to platform: Unix is \n, Windows is \r\n, and Macintosh is \n. One way to enter a newline character programatically is to test the appVersion property to determine the current platform and set the newline character accordingly. See the appVersion property for an example.
The following example creates a textarea object that is 6 rows long and 55 columns wide. The textarea field appears immediately below the word "描述:". When the form loads, the textarea object contains several lines of data, including one blank line.
The title property is a reflection of the value specified within the <TITLE> and </TITLE> tags. If a document does not have a title, the title property is null.
title is a read-only property.
例子
In the following example, the value of the title property is assigned to a variable called docTitle:
var newWindow = window.open("http://www.netscape.com")
var docTitle = newWindow.document.title
The exact format of the value returned by toGMTString varies according to the platform.
例子
In the following example, today is a date object:
today.toGMTString()
In this example, the toGMTString method converts the date to GMT (UTC) using the operating system's time zone offset and returns a string value that is similar to the following form. The exact format depends on the platform.
If you are trying to pass a date using toLocaleString, be aware that different locales assemble the string in different ways. Using methods such as getHours, getMinutes, and getSeconds will give more portable results.
例子
In the following example, today is a date object:
today.toLocaleString()
In this example, toLocaleString returns a string value that is similar to the following form. The exact format depends on the platform.
propertyName is defaultStatus, status, or length. methodName is any method associated with the window object. frameName and frames[index] are ways to refer to frames.
The top property refers to the top-most window that contains frames or nested framesets. Use the top property to refer to this ancestor window.
The top property is read-only. The value of the top property is
<object objectReference>
where objectReference is an internal reference.
例子
The statement top.close() closes the top-most ancestor window.
The statement top.length specifies the number of frames contained within the top-most ancestor window. When the top-most ancestor is defined as follows, top.length returns 3: