分享
 
 
 

javascript手冊-p&q

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

parent property

The parent property is a synonym for a window or frame whose frameset contains the current frame.

语法1. parent.propertyName

2. parent.methodName

3. parent.frameName

4. parent.frames[index]

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

propertyName is the length, name, or parent property when the calling parent refers to a frame object.

methodName is any method associated with the window object.

frameName and frames[index] are ways to refer to frames.

Property of

frame, window

Description

The parent property refers to the <FRAMESET> window of a frame. Child frames within a frameset refer to sibling frames by using "parent" in place of the window name as follows: parent.frameName or parent.frames[index]. For example, if the fourth frame in a set has NAME="homeFrame", sibling frames can refer to that frame using parent.homeFrame or parent.frames[3].

You can use parent.parent to refer to the "grandparent" frame or window when a <FRAMESET> tag is nested within a child frame.

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

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

例子

See the 例子 for the frame object.

parse method

Returns the number of milliseconds in a date string since January 1, 1970 00:00:00, local time.

语法Date.parse(dateString)

dateString is a string representing a date or a property of an existing object.

Method of

Date

Description

The parse method takes a date string (such as "Dec 25, 1995"), and returns the number of milliseconds since January 1, 1970 00:00:00 (local time). This function is useful for setting date values based on string values, for example in conjunction with the setTime method and the Date object.

Given a string representing a time, parse returns the time value. It accepts the IETF standard date 语法: "Mon, 25 Dec 1995 13:30:00 GMT". It understands the continental US time zone abbreviations, but for general use, use a time zone offset, for example "Mon, 25 Dec 1995 13:30:00 GMT+0430" (4 hours, 30 minutes west of the Greenwich meridian). If you do not specify a time zone, the local time zone is assumed. GMT and UTC are considered equivalent.

Because the parse function is a static method of Date, you always use it as Date.parse(), rather than as a method of a date object you created.

例子

If IPOdate is an existing date object, then IPOdate.setTime(Date.parse("Aug 9, 1995"))

相关

UTC method

parseFloat function

Parses a string argument and returns a floating point number.

语法parseFloat(string)

string is a string that represents the value you want to parse.

Description

The parseFloat function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.

parseFloat parses its argument, a string, and returns a floating point number. If it encounters a character other than a sign ( + or -), numeral (0-9), a decimal point, or an exponent, then it returns the value up to that point and ignores that character and all succeeding characters.

If the first character cannot be converted to a number, parseFloat returns one of the following values:

0 on Windows platforms.

"NaN" on any other platform, indicating that the value is not a number.

For arithmetic purposes, the "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseFloat is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".

例子

The following 例子 all return 3.14: parseFloat("3.14")

parseFloat("314e-2")

parseFloat("0.0314E+2")

var x = "3.14"

parseFloat(x)

The following example returns "NaN" or 0: parseFloat("FF2")

相关

isNaN, parseInt functions

parseInt function

Parses a string argument and returns an integer of the specified radix or base.

语法parseInt(string [,radix])

string is a string that represents the value you want to parse.

radix is an integer that represents the radix of the return value.

Description

The parseInt function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.

The parseInt function parses its first argument, a string, and attempts to return an integer of the specified radix (base). For example, a radix of 10 indicates to convert to a decimal number, 8 octal, 16 hexadecimal, and so on. For radixes above 10, the letters of the alphabet indicate numerals greater than 9. For example, for hexadecimal numbers (base 16), A through F are used.

If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. ParseInt truncates numbers to integer values.

If the radix is not specified or is specified as 0, JavaScript assumes the following:

If the input string begins with "0x", the radix is 16 (hexadecimal).

If the input string begins with "0", the radix is 8 (octal).

If the input string begins with any other value, the radix is 10 (decimal).

If the first character cannot be converted to a number, parseFloat returns one of the following values:

0 on Windows platforms.

"NaN" on any other platform, indicating that the value is not a number.

For arithmetic purposes, the "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseInt is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".

例子

The following 例子 all return 15: parseInt("F", 16)

parseInt("17", 8)

parseInt("15", 10)

parseInt(15.99, 10)

parseInt("FXX123", 16)

parseInt("1111", 2)

parseInt("15*3", 10)

The following 例子 all return "NaN" or 0: parseInt("Hello", 8)

parseInt("0x7", 10)

parseInt("FFF", 10)

Even though the radix is specified differently, the following 例子 all return 17 because the input string begins with "0x". parseInt("0x11", 16)

parseInt("0x11", 0)

parseInt("0x11")

相关

isNaN, parseFloat functions

password object

A text field on an htm form that conceals its value by displaying asterisks (*). When the user enters text into the field, asterisks (*) hide anything entered from view.

语法

To define a password object, use standard htm 语法: <INPUT

TYPE="password"

NAME="passwordName"

[VALUE="textValue"]

SIZE=integer>

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

VALUE="textValue" specifies the initial value of the password object. You can access this value using the defaultValue property.

SIZE=integer specifies the number of characters the password object can accommodate without scrolling.

To use a password object's properties and methods: 1. passwordName.propertyName

2. passwordName.methodName(parameters)

3. formName.elements[index].propertyName

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

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

propertyName is one of the properties listed below.

methodName is one of the methods listed below.

Property of

form

Description

A password object on a form looks as follows:

Enter your password:

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

Properties

defaultValue reflects the VALUE attribute

name reflects the NAME attribute

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

Methods

focus

blur

select

Event handlers

None.

例子

Password:

相关

form and text objects

pathname property

A string specifying the url-path portion of the URL.

语法1. links[index].pathname

2. location.pathname

index is an integer representing a link object.

Property of

link, location

Description

The pathname property specifies a portion of the URL. The pathname supplies the details of how the specified resource can be accessed.

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

See Section 3.1 of RFC 1738 for complete information about the pathname.

例子

See the 例子 for the href property.

相关

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

PI property

The ratio of the circumference of a circle to its diameter, approximately 3.14159.

语法Math.PI

Property of

Math

Description

Because PI is a constant, it is a read-only property of Math.

例子

The following example displays the value of pi: document.write("The value of pi is " + Math.PI)

相关

E, LN2, LN10, LOG2E, LOG10E, SQRT1_2, SQRT2 properties

port property

A string specifying the communications port that the server uses for communications.

语法1. links[index].port

2. location.port

index is an integer representing a link object.

Property of

link, location

Description

The port property specifies a portion of the URL. The port property is a substring of the host property. The host property is the concatenation of the hostname and port properties, separated by a colon. When the port property is not defined, the host property is the same as the hostname property.

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

See Section 3.1 of RFC 1738 for complete information about the port.

例子

See the 例子 for the href property.

相关

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

pow method

Returns base to the exponent power, that is, baseexponent.

语法Math.pow(base, exponent)

base is any numeric expression or a property of an existing object.

exponent is any numeric expression or a property of an existing object. If the result would include an imaginary number (for example pow(-1, 0.5)), then the value returned is always zero.

Method of

Math

例子//Displays the value 49

document.write("7 to the power of 2 is " + Math.pow(7,2))

//Displays the value 1024

document.write("<P>2 to the power of 10 is " + Math.pow(2,10))

相关

exp, log methods

prompt method

Displays a Prompt dialog box with a message and an input field.

语法prompt(message, [inputDefault])

message is any string or a property of an existing object; the string is displayed as the message.

inputDefault is a string, integer, or property of an existing object that represents the default value of the input field.

Method of

window

Description

Use the prompt method to display a dialog box that receives user input. If you do not specify an initial value for inputDefault, the dialog box displays the value <undefined>.

Although prompt is a method of the window object, you do not need to specify a windowReference when you call it. For example, windowReference.prompt() is unnecessary.

例子prompt("Enter the number of cookies you want to order:", 12)

相关

alert, confirm methods

protocol property

A string specifying the beginning of the URL, up to and including the first colon.

语法1. links[index].protocol

2. location.protocol

index is an integer representing a link object.

Property of

link, location

Description

The protocol property specifies a portion of the URL. The protocol indicates the access method of the URL. For example, a protocol of "http:" specifies Hypertext Transfer Protocol, and a protocol of "javascript:" specifies JavaScript code.

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

The protocol property represents the scheme name of the URL. See Section 2.1 of RFC 1738 for complete information about the protocol.

例子

See the 例子 for the href property.

相关

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
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- 王朝網路 版權所有