分享
 
 
 

javascript手冊-s1

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

search property

A string beginning with a question mark that specifies any query information in the URL.

语法1. links[index].search

2. location.search

index is an integer representing a link object.

Property of

link, location

描述

The search property specifies a portion of the URL.

You can set the search property at any time, although it is safer to set the href property to change a location. If the search that you specify cannot be found in the current location, you will get an error.

See Section 3.3 of RFC 1738 for complete information about the search.

例子

In the following example, the window.open statement creates a window called newWindow and loads the specified URL into it. The document.write statements display all the properties of newWindow.location in a window called msgWindow. newWindow=window.open

("http://guide-p.infoseek.com/WW/NS/Titles?qt=RFC+1738+&col=WW")

msgWindow.document.write("newWindow.location.href = " +

newWindow.location.href + "<P>")

msgWindow.document.write("newWindow.location.protocol = " +

newWindow.location.protocol + "<P>")

msgWindow.document.write("newWindow.location.host = " +

newWindow.location.host + "<P>")

msgWindow.document.write("newWindow.location.hostName = " +

newWindow.location.hostName + "<P>")

msgWindow.document.write("newWindow.location.port = " +

newWindow.location.port + "<P>")

msgWindow.document.write("newWindow.location.pathname = " +

newWindow.location.pathname + "<P>")

msgWindow.document.write("newWindow.location.search = " +

newWindow.location.search + "<P>")

msgWindow.document.write("newWindow.location.hash = " +

newWindow.location.hash + "<P>")

msgWindow.document.close()

The previous example displays the following output: newWindow.location.href =

http://guide-p.infoseek.com/WW/NS/Titles?qt=RFC+1738+&col=WW

newWindow.location.protocol = http:

newWindow.location.host = guide-p.infoseek.com

newWindow.location.hostName = guide-p.infoseek.com

newWindow.location.port =

newWindow.location.pathname = /WW/NS/Titles

newWindow.location.search = ?qt=RFC+1738+&col=WW

newWindow.location.hash =

相关

hash, host, hostname, href, pathname, port, protocol properties

select method

Selects the input area of the specified password, text, or textarea object.

语法1. passwordName.select()

2. textName.select()

3. textareaName.select()

passwordName is either the value of the NAME attribute of a password object or an element in the elements array.

textName is either the value of the NAME attribute of a text object or an element in the elements array.

textareaName is either the value of the NAME attribute of a textarea object or an element in the elements array.

方法

password, text, textarea

描述

Use the select method to highlight the input area of a form element. You can use the select method with the focus method to highlight a field and position the cursor for a user response.

例子

In the following example, the checkPassword function confirms that a user has entered a valid password. If the password is not valid, the select method highlights the password field and the focus method returns focus to it so the user can re-enter the password. function checkPassword(userPass) {

if (badPassword) {

alert("Please enter your password again.")

userPass.focus()

userPass.select()

}

}

This example assumes that the password is defined as: <INPUT TYPE="password" NAME="userPass">

相关

blur, focus methods

select object (options array)

A selection list or scrolling list on an htm form. A selection list lets the user choose one item from a list. A scrolling list lets the user choose one or more items from a list.

语法

To define a select object, use standard htm 语法 with the addition of the onBlur, onChange, and onFocus event handlers: <SELECT

NAME="selectName"

[SIZE="integer"]

[MULTIPLE]

[onBlur="handlerText"]

[onChange="handlerText"]

[onFocus="handlerText"]>

<OPTION VALUE="optionValue" [SELECTED]> textToDisplay [ ... <OPTION> textToDisplay]

</SELECT>

NAME="selectName" specifies the name of the select object. You can access this value using the name property.

SIZE="integer" specifies the number of options visible when the form is displayed.

MULTIPLE specifies that the select object is a scrolling list (not a selection list).

OPTION specifies a selection element in the list. You can access the options using the options array.

VALUE="optionValue" specifies a value that is returned to the server when the option is selected and the form is submitted. You can access this value using the value property.

SELECTED specifies that the option is selected by default. You can access this value using the defaultSelected property.

textToDisplay specifies the text to display in the list. You can access this value using the text property.

To use a select object's properties and methods: 1. selectName.propertyName

2. selectName.methodName(parameters)

3. formName.elements[index].propertyName

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

selectName is the value of the NAME attribute of a select 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 select object on a form.

propertyName is one of the properties listed below.

methodName is one of the methods listed below.

To use an option's properties: 1. selectName.options[index1].propertyName

2. formName.elements[index2].options[index1].propertyName

selectName is the value of the NAME attribute of a select object.

index1 is an integer representing an option in a select object.

formName is either the value of the NAME attribute of a form object or an element in the forms array.

index2 is an integer representing a select object on a form.

propertyName is one of the properties listed below.

Property of

The select object is a property of form

The options array is a property of select

描述

A select object on a form looks as follows. The object on the left is a selection list that lets the user choose one item; the object on the right is a scrolling list that lets the user choose one or more items:

R&BJazzBluesNew Age R&BJazzBluesNew Age

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

The options array

You can reference the options of a select object in your code by using the options array. This array contains an entry for each option in a select object (<OPTION> tag) in source order. For example, if a select object named musicStyle contains three options, these options are reflected as musicStyle.options[0], musicStyle.options[1], and musicStyle.options[2].

To use the options array: 1. selectName.options

2. selectName.options[index]

3. selectName.options.length

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.

To obtain the number of options in a select object, use the length property of either the options array or the select object: 1. selectName.length

2. selectName.options.length

The select object has properties that you can access only through the options array. These properties are listed below.

Even though each element in the options array represents a select option, the value of options[index] is always null. The value returned by selectName.options represents the full htm statement for the selectName object.

Elements in the options array are read-only. For example, the statement selectName.options[0]="guitar" has no effect.

Properties

The select object has the following properties:

length reflects the number of options in a select object

name reflects the NAME attribute

options reflects the <OPTION> tags

selectedIndex reflects the index of the selected option (or the first selected option, if multiple options are selected)

The options array has the following properties:

defaultSelected reflects the SELECTED attribute

index reflects the index of an option

length reflects the number of options in a select object

name reflects the NAME attribute

selected lets you programatically select an option

selectedIndex reflects the index of the selected option

text reflects the textToDisplay that follows an <OPTION> tag

value reflects the VALUE attribute

Methods

blur

focus

Event handlers

onBlur

onChange

onFocus

例子

Example 1. The following example displays a selection list and a scrolling list. Choose the music type for your free CD:

R&B

Jazz

Blues

New Age

Choose the music types for your free CDs:

R&B

Jazz

Blues

New Age

Example 2. The following example displays two selection lists that let the user choose a month and day. These selection lists are initialized to the current date. The user can change the month and day by using the selection lists or by choosing preset dates from radio buttons. Text fields on the form display the values of the select object's properties and indicate the date chosen and whether it is Cinco de Mayo.

Select object example

Choose a month and day:

Month:

January February March

April May June

July August September

October November December

Day:

1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 25

26 27 28 29 30

31

Set the date to:

New Year's Day

Cinco de Mayo

Summer Solstice

Property values:

Date chosen:

monthSelection.length

daySelection.length

monthSelection.name

daySelection.name

monthSelection.selectedIndex

daySelection.selectedIndex

Is it Cinco de Mayo?

相关 the 例子 for the defaultSelected property.

相关

form and radio objects

selected property

A Boolean value specifying the current selection state of an option in a select object.

语法selectName.options[index].selected

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

描述

If an option in a select object is selected, the value of its selected property is true; otherwise, it is false.

You can set the selected property at any time. The display of the select object updates immediately when you set the selected property.

In general, the selected property is more useful than the selectedIndex property for select objects that are created with the MULTIPLE attribute. With the selected property, you can evaluate every option in the options array to determine multiple selections, and you can select individual options without clearing the selection of other options.

例子

See the 例子 for the defaultSelected property.

相关

defaultSelected, index, selectedIndex properties

selectedIndex property

An integer specifying the index of the selected option in a select object.

语法1. selectName.selectedIndex

2. selectName.options.selectedIndex

selectName is either the value of the NAME attribute of a select object or an element in the elements array.

Property of

select

options array

描述

Options in a select object are indexed in the order in which they are defined, starting with an index of 0. You can set the selectedIndex property at any time. The display of the select object updates immediately when you set the selectedIndex property. Both forms of the 语法 specify the same value.

In general, the selectedIndex property is more useful for select objects that are created without the MULTIPLE attribute. If you evaluate selectedIndex when multiple options are selected, the selectedIndex property specifies the index of the first option only. Setting selectedIndex clears any other options that are selected in the select object.

The selected property of the select object's options array is more useful for select objects that are created with the MULTIPLE attribute. With the selected property, you can evaluate every option in the options array to determine multiple selections, and you can select individual options without clearing the selection of other options.

例子

In the following example, the getSelectedIndex() function returns the selected index in the musicType select object: function getSelectedIndex() {

return document.musicForm.musicType.selectedIndex

}

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>

相关

defaultSelected, index, selected properties

self property

The self property is a synonym for the current window or frame.

语法1. self.propertyName

2. self.methodName

propertyName is the defaultStatus, status, length, or name property when self refers to a window object.

propertyName is the length or name property when self refers to a frame object.

methodName is any method associated with the window object.

Property of

frame, window

描述

The self property refers to the current window or frame.

Use the self property to disambiguate a window property from a form or form element of the same name. You can also use the self property to make your code more readable.

The self property is read-only. The value of the self property is <object nameAttribute>

where nameAttribute is the NAME attribute if self refers to a frame, or an internal reference if self refers to a window.

例子

In the following example, self.status is used to set the status property of the current window. This usage disambiguates the status property of the current window from a form or form element called "status" within the current window. Go!

相关

window property

setDate method

Sets the day of the month for a specified date.

语法dateObjectName.setDate(dayValue)

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

dayValue is an integer from 1 to 31 or a property of an existing object, representing the day of the month.

方法

Date

例子

The second statement below changes the day for theBigDay to the 24th of July from its original value. theBigDay = new Date("July 27, 1962 23:30:00")

theBigDay.setDate(24)

相关

getDate method

setHours method

Sets the hours for a specified date.

语法dateObjectName.setHours(hoursValue)

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

hoursValue is an integer between 0 and 23 or a property of an existing object, representing the hour.

方法

Date

例子theBigDay.setHours(7)

相关

getHours method

setMinutes method

Sets the minutes for a specified date.

语法dateObjectName.setMinutes(minutesValue)

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

minutesValue is an integer between 0 and 59 or a property of an existing object, representing the minutes.

方法

Date

例子theBigDay.setMinutes(45)

相关

getMinutes method

setMonth method

Sets the month for a specified date.

语法dateObjectName.setMonth(monthValue)

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

monthValue is an integer between 0 and 11 (representing the months January through December), or a property of an existing object.

方法

Date

例子theBigDay.setMonth(6)

相关

getMonth method

setSeconds method

Sets the seconds for a specified date.

语法dateObjectName.setSeconds(secondsValue)

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

secondsValue is an integer between 0 and 59 or a property of an existing object.

方法

Date

例子theBigDay.setSeconds(30)

相关

getSeconds 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- 王朝網路 版權所有