分享
 
 
 

javascript手冊-t

王朝html/css/js·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

tan method

Returns the tangent of a number.

语法Math.tan(number)

number is a numeric expression representing the size of an angle in radians, or a property of an existing object.

用法

Math

描述

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))

相关

acos, asin, atan, cos, sin methods

target property

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.

Property of

form, link

描述

The target property initially reflects the TARGET attribute of the <FORM> and <A> tags; however, setting target overrides these attributes.

The target property cannot be assigned the value of a JavaScript expression or variable.

You can set the target property at any time.

Certain values of the target property may require specific values for other form properties. See RFC 1867 for more information.

例子

The following example specifies that responses to the musicInfo form are displayed in the "msgWindow" window: document.musicInfo.target="msgWindow"

相关

For form:

action, encoding, method properties

text object

A text input field on an htm form. A text field lets the user enter a word, phrase, or series of numbers.

语法

To define a text object, use standard htm 语法 with the addition of the onBlur, on Change, onFocus, and onSelect event handlers: <INPUT

TYPE="text"

NAME="textName"

VALUE="textValue"

SIZE=integer

[onBlur="handlerText"]

[onChange="handlerText"]

[onFocus="handlerText"]

[onSelect="handlerText"]>

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.

To use a text object's properties and methods: 1. textName.propertyName

2. textName.methodName(parameters)

3. formName.elements[index].propertyName

4. formName.elements[index].methodName(parameters)

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.

Property of

form

描述

A text object on a form looks as follows:

Last name:

A text object is a form element and must be defined within a <FORM> tag.

text objects can be updated (redrawn) dynamically by setting the value property (this.value).

Properties

defaultValue reflects the VALUE attribute

name reflects the NAME attribute

value reflects the current value of the text object's field

Methods

focus

blur

select

Event handlers

onBlur

onChange

onFocus

onSelect

例子

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.

City:

State:

相关 the 例子 for the onBlur, onChange, onFocus, and onSelect event handlers.

相关

form, password, string, and textarea objects

text property

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.

Property of

options array

描述

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>

textarea object

A multiline input field on an htm form. A textarea field lets the user enter words, phrases, or numbers.

语法

To define a text area, use standard htm 语法 with the addition of the onBlur, onChange, onFocus, and onSelect event handlers: <TEXTAREA

NAME="textareaName"

ROWS="integer"

COLS="integer"

WRAP="off|virtual|physical"

[onBlur="handlerText"]

[onChange="handlerText"]

[onFocus="handlerText"]

[onSelect="handlerText"]>

textToDisplay

</TEXTAREA>

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: 1. textareaName.propertyName

2. textareaName.methodName(parameters)

3. formName.elements[index].propertyName

4. formName.elements[index].methodName(parameters)

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.

Property of

form

描述

A textarea object on a form looks as follows:

Our storage ottoman provides an attractive way to

store lots of CDs and videos--and it's versatile

enough to store other things as well.

It can hold up to 72 CDs under the lid and 20 videos

in the drawer 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.

Properties

defaultValue reflects the VALUE attribute

name reflects the NAME attribute

value reflects the current value of the textarea object

Methods

focus

blur

select

Event handlers

onBlur

onChange

onFocus

onSelect

例子

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. 描述:

Our storage ottoman provides an attractive way to

store lots of CDs and videos--and it's versatile

enough to store other things as well.

It can hold up to 72 CDs under the lid and 20 videos

in the drawer below.

相关 the 例子 for the onBlur, onChange, onFocus, and onSelect event handlers.

相关

form, password, string, and text objects

title property

A string representing the title of a document.

语法document.title

Property of

document

描述

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

toGMTString method

Converts a date to a string, using the Internet GMT conventions.

语法dateObjectName.toGMTString()

dateObjectName is either the name of a date object or a property of an existing object.

用法

Date

描述

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.

Mon, 18 Dec 1995 17:28:35 GMT

相关

toLocaleString method

toLocaleString method

Converts a date to a string, using the current locale's conventions.

语法dateObjectName.toLocaleString()

dateObjectName is either the name of a date object or a property of an existing object.

用法

Date

描述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.

12/18/95 17:28:35

相关

toGMTString method

toLowerCase method

Returns the calling string value converted to lower case.

语法stringName.toLowerCase()

stringName is any string or a property of an existing object.

用法

string

描述

The toLowerCase method returns the value of stringName converted to lower case. toLowerCase does not affect the value of stringName itself.

例子

The following 例子 both yield "alphabet". var upperText="ALPHABET"

document.write(upperText.toLowerCase())

"ALPHABET".toLowerCase()

相关

toUpperCase method

top property

The top property is a synonym for the top-most Navigator window, which is a "document window" or "Web Browser window."

语法1. top.propertyName

2. top.methodName

3. top.frameName

4. top.frames[index]

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.

Property of

window

描述

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: <FRAMESET COLS="30%,40%,30%">

<FRAME SRC=child1.htm NAME="childFrame1">

<FRAME SRC=child2.htm NAME="childFrame2">

<FRAME SRC=child3.htm NAME="childFrame3">

</FRAMESET>

The following example sets the background color of a frame called myFrame to red. myFrame is a child of the top-most ancestor window. top.myFrame.document.bgColor="red"

toUpperCase method

Returns the calling string value converted to upper case.

语法stringName.toUpperCase()

stringName is any string or a property of an existing object.

用法

string

描述

The toUpperCase method returns the value of stringName converted to upper case. toUpperCase does not affect the value of stringName itself.

例子

The following 例子 both yield "ALPHABET". var lowerText="alphabet"

document.write(lowerText.toUpperCase())

"alphabet".toUpperCase()

相关

toLowerCase method

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有