javascript手冊-t
2007-11-27 17:50:33 来源:WEB开发网 闂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾惧綊鏌熼梻瀵割槮缁炬儳缍婇弻鐔兼⒒鐎靛壊妲紒鐐劤缂嶅﹪寮婚悢鍏尖拻閻庨潧澹婂Σ顔剧磼閻愵剙鍔ょ紓宥咃躬瀵鎮㈤崗灏栨嫽闁诲酣娼ф竟濠偽i鍓х<闁绘劦鍓欓崝銈囩磽瀹ュ拑韬€殿喖顭烽幃銏ゅ礂鐏忔牗瀚介梺璇查叄濞佳勭珶婵犲伣锝夘敊閸撗咃紲闂佺粯鍔﹂崜娆撳礉閵堝洨纾界€广儱鎷戦煬顒傗偓娈垮枛椤兘骞冮姀銈呯閻忓繑鐗楃€氫粙姊虹拠鏌ュ弰婵炰匠鍕彾濠电姴浼i敐澶樻晩闁告挆鍜冪床闂備浇顕栭崹搴ㄥ礃閿濆棗鐦遍梻鍌欒兌椤㈠﹤鈻嶉弴銏犵闁搞儺鍓欓悘鎶芥煛閸愩劎澧曠紒鈧崘鈹夸簻闊洤娴烽ˇ锕€霉濠婂牏鐣洪柡灞诲妼閳规垿宕卞▎蹇撴瘓缂傚倷闄嶉崝搴e垝椤栫偛桅闁告洦鍨扮粻鎶芥倵閿濆簼绨藉ù鐘荤畺濮婃椽妫冨☉娆愭倷闁诲孩鐭崡鎶芥偘椤曗偓瀹曞爼顢楁径瀣珫婵犳鍣徊鍓р偓绗涘洤绠查柛銉墮閽冪喖鏌i弬鎸庢喐闁荤喎缍婇弻娑⑩€﹂幋婵囩亪濡炪値鍓欓悧鍡涒€旈崘顔嘉ч幖绮光偓鑼嚬缂傚倷绶¢崰妤呭箰閹间焦鍋╅柣鎴f绾偓闂佺粯鍔曠粔闈浳涢崘顔兼槬闁逞屽墯閵囧嫰骞掗幋婵愪紑閻庤鎸风粈渚€鍩為幋锔藉亹闁圭粯甯╂导鈧紓浣瑰劤瑜扮偟鍒掑▎鎾宠摕婵炴垶鐭▽顏堟煙鐟欏嫬濮囨い銉︾箞濮婃椽鏌呴悙鑼跺濠⒀傚嵆閺岀喖鎼归锝呯3闂佹寧绻勯崑娑㈠煘閹寸姭鍋撻敐搴樺亾椤撴稒娅婇柡灞界У濞碱亪骞忕仦钘夊腐闂備焦鐪归崐鏇㈠箠閹邦喗顫曢柟鎯х摠婵挳鏌涢幘鏉戠祷闁告挸宕—鍐Χ閸℃浠搁梺鑽ゅ暱閺呮盯鎮鹃悜钘壩ㄧ憸澶愬磻閹剧粯鏅查幖绮瑰墲閻忓秹姊虹紒妯诲鞍婵炲弶锕㈡俊鐢稿礋椤栨氨鐤€闂傚倸鐗婄粙鎰姳閼测晝纾藉ù锝堟閻撴劖鎱ㄥΟ绋垮婵″弶鍔欓獮妯兼嫚閼碱剦妲伴梻浣稿暱閹碱偊宕愭繝姣稿洭寮舵惔鎾存杸濡炪倖姊婚妴瀣啅閵夛负浜滄い鎾跺仜濡插鏌i敐鍥у幋妤犵偞甯¢獮瀣籍閳ь剟鎮楁繝姘拺閻熸瑥瀚崕妤呮煕濡 鍋撻悢鎻掑緧婵犵數濮烽弫鍛婃叏閻戣棄鏋侀柛娑橈攻閸欏繑銇勯幘鍗炵仼缁炬儳顭烽弻鐔煎礈瑜忕敮娑㈡煃闁垮鐏﹂柕鍥у楠炴帡宕卞鎯ь棜缂傚倸鍊风粈渚€藝闁秴鏋佸┑鐘虫皑瀹撲線鏌涢埄鍐姇闁稿﹦鍏橀弻娑樷攽閸℃浼€濡炪倖姊归崝鏇㈠煘閹达附鍊婚柛銉㈡櫇鏍¢梻浣告啞閹稿鎮烽敂鐣屸攳濠电姴娲﹂崵鍐煃閸濆嫬鏆熼柨娑欑矒濮婇缚銇愰幒鎴滃枈闂佸憡鐟ユ鎼佸煝閹炬枼鍫柛顐ゅ枔閸樻悂鏌h箛鏇炰户缁绢厼鐖煎畷鎴﹀箻鐠囪尙鐤€婵炶揪绲介幉锟犲磹椤栫偞鈷戠痪顓炴噹娴滃綊鎮跺☉鏍у姦闁糕斁鍋撳銈嗗笒閸燁偊鎯冨ú顏呯厸濞达絽婀辨晶顏堟煃鐟欏嫬鐏撮柟顔界懇瀵爼骞嬮悩杈敇闂傚倷绀佸﹢杈ㄧ仚闂佺濮ょ划搴ㄥ礆閹烘绫嶉柛顐ゅ枎娴犺櫣绱撴担鍓插創妞ゆ洘濞婇弫鍐磼濞戞艾骞堥梻浣告惈濞层垽宕濆畝鍕€堕柣妯肩帛閻撴洟鏌熼懜顒€濡煎ù婊勫劤閳规垿鏁嶉崟顐℃澀闂佺ǹ锕ラ悧鐘茬暦濠靛鏅濋柍褜鍓熼垾锕傚锤濡も偓閻掑灚銇勯幒宥堝厡缂佺姴澧介埀顒€鍘滈崑鎾斥攽閻樿京绐旈柛瀣殔閳规垿顢欑涵鐑界反濠电偛鎷戠徊鍨i幇鏉跨闁瑰啿纾崰鎾诲箯閻樼粯鍤戦柤绋跨仛濮f劙姊婚崒姘偓鐑芥嚄閼哥數浠氭繝鐢靛仜椤曨參宕楀Ο渚殨妞ゆ劑鍊栫€氭氨鈧懓澹婇崰鏍р枔閵婏妇绡€闁汇垽娼ф牎缂佺偓婢樼粔鐟邦嚕閺屻儱绠甸柟鐑樼箘閸炵敻鏌i悩鐑橆仩閻忓繈鍔岄蹇涘Ψ瑜夐崑鎾舵喆閸曨剙纰嶅┑鈽嗗亝缁诲倿锝炶箛娑欐優闁革富鍘鹃敍婊冣攽閳藉棗鐏犻柟纰卞亰閿濈偛顓奸崶鈺冿紳婵炶揪缍侀ˉ鎾诲礉瀹ュ鐓欑紒瀣仢閺嗛亶鏌i敐鍥у幋妤犵偛顑夐弫鍐焵椤掑倻涓嶅┑鐘崇閸嬶綁鏌涢妷鎴濆暟妤犲洭鎮楃憴鍕碍缂佸鎸抽垾鏃堝礃椤斿槈褔鏌涢埄鍏狀亪妫勫鍥╃=濞达絽澹婇崕鎰版煕閵娿儱顣崇紒顔碱儏椤撳吋寰勭€n亖鍋撻柨瀣ㄤ簻闁瑰搫绉堕ˇ锔锯偓娈垮枛閻忔繈鍩為幋锕€鐓¢柛鈩冾殘娴狀垶姊洪崨濠庣劶闁告洦鍙庡ú鍛婁繆閵堝繒鍒伴柛鐕佸灦瀹曟劙宕归锝呭伎濠碘槅鍨抽崢褎绂嶆ィ鍐╁€垫慨妯煎亾鐎氾拷

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.9999999999999999document.write(The tangent of pi/4 radians is + Math.tan(Math.PI/4))//Displays the value 0document.write(<P>The tangent of 0 radians is + Math.tan(0))
相关
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.target2. 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:
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 objects properties and methods:
1. textName.propertyName2. textName.methodName(parameters)3. formName.elements[index].propertyName4. 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
描述
A text object on a form looks as follows:
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
Methods
Event handlers
例子
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.
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.
相关 the 例子 for the onBlur, onChange, onFocus, and onSelect event handlers.
相关
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:
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 objects properties and methods:
1. textareaName.propertyName2. textareaName.methodName(parameters)3. formName.elements[index].propertyName4. 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
描述
A textarea object on a form looks as follows:
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
Methods
Event handlers
例子
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 例子 for the onBlur, onChange, onFocus, and onSelect event handlers.
相关
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 systems 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
Converts a date to a string, using the current locales 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
相关
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=ALPHABETdocument.write(upperText.toLowerCase())ALPHABET.toLowerCase()
相关
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.propertyName2. top.methodName3. top.frameName4. 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 objectR
更多精彩
赞助商链接