## Math object

A built-in object that has properties and methods for mathematical constants and functions. For example, the Math object's PI property has the value of pi.

### Syntax

To use a Math object:

```1. Math.propertyName
2. Math.methodName(parameters)
```
propertyName is one of the properties listed below.
methodName is one of the methods listed below.

• None.

### Description

The Math object is a built-in JavaScript object.

You reference the constant PI as Math.PI. Constants are defined with the full precision of real numbers in JavaScript.

Similarly, you reference Math functions as methods. For example, the sine function is Math.sin(argument), where argument is the argument.

It is often convenient to use the with statement when a section of code uses several Math constants and methods, so you don't have to type "Math" repeatedly. For example,

```with (Math) {
a = PI * r*r
y = r*sin(theta)
x = r*cos(theta)
}
```

• E
• LN2
• LN10
• LOG2E
• LOG10E
• PI
• SQRT1_2
• SQRT2

• abs
• acos
• asin
• atan
• ceil
• cos
• exp
• floor
• log
• max
• min
• pow
• random
• round
• sin
• sqrt
• tan

### Event handlers

• None. Built-in objects do not have event handlers.

### Examples

See the examples for the individual properties and methods.

## max method

Returns the greater of two numbers.

### Syntax

`Math.max(number1, number2)`
number1 and number2 are any numeric arguments or the properties of existing objects.

### Examples

```//Displays the value 20
document.write("The maximum value is " + Math.max(10,20))

//Displays the value -10
document.write("<P>The maximum value is " + Math.max(-10,-20))
```

• min method

## method property

A string specifying how form field input information is sent to the server.

### Syntax

`formName.method`

formName is either the name of a form or an element in the forms array.

### Description

The method property is a reflection of the METHOD attribute of the <FORM> tag. The method property should evaluate to either "get" or "post".

You can set the method property at any time.

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

### Examples

The following function returns the value of the musicForm method property:

```function getMethod() {
return document.musicForm.method
}
```

• action, encoding, target properties

## min method

Returns the lesser of two numbers.

### Syntax

`Math.min(number1, number2)`
number1 and number2 are any numeric arguments or the properties of existing objects.

### Examples

```//Displays the value 10
document.write("The minimum value is " + Math.min(10,20))

//Displays the value -20
document.write("<P>The minimum value is " + Math.min(-10,-20))
```

• max method

## name property

A string specifying the name of an object.

### Syntax

```1. objectName.name
2. frameReference.name
3. frameReference.frames.name
5. selectName.options.name
6. windowReference.name
7. windowReference.frames.name
```

objectName is either the value of the NAME attribute of any of the objects listed below or an element in the elements array.
frameReference is a valid way of referring to a frame, as described in the frame object.
radioName is the value of the NAME attribute of a radio object.
selectName is either the value of the NAME attribute of a select object or an element in the elements array.
windowReference is a valid way of referring to a window, as described in the window object.

### Property of

• button, checkbox, frame, hidden, password, radio, reset, select, submit, text, textarea, window
• options array

### Description

The value of the name property differs between the window object and other objects.

#### window object

The name property for the window object is represented by form 6 and form 7 of the syntax. The name property represents the value of the windowName argument described in the window object syntax. Both forms of the syntax represent the same value.

name is a read-only property.

#### All other objects

The name property for all objects except window is represented by forms 1 through 5 of the syntax. For all objects except window, the name property initially reflects the value of the NAME attribute. Changing the name property overrides this setting.

You can set the name property at any time.

The name property is the same for every radio button in a single radio object. Individual radio buttons are referenced by their position in the radio array.

Do not confuse the name property with the label displayed on a button, reset, or submit object. The value property specifies the label for these objects. The name property is not displayed onscreen; it is used to reference the objects programatically.

For a select object, the values specified by form 1 and form 5 of the syntax are the same. For a frame object, the values specified by forms 1, 2, and 3 of the syntax are the same.

If multiple objects on the same form have the same NAME attribute, an array of the given name is created automatically. Each element in the array represents an individual form object. Elements are indexed in source order starting at 0. For example, if two text elements and a textarea element on the same form have their NAME attribute set to "myField", an array with the elements myField[0], myField[1], and myField[2] is created.

### Examples

In the following example, the valueGetter() function uses a for loop to iterate over the array of elements on the valueTest form. The msgWindow window displays the names of all the elements on the form:

```newWindow=window.open("http://www.netscape.com")

function valueGetter() {
var msgWindow=window.open("")
for (var i = 0; i < newWindow.document.valueTest.elements.length; i++) {
msgWindow.document.write(newWindow.document.valueTest.elements[i].name + "<BR>")
}
}
```
In the following example, the first statement creates a window called netscapeWin. The second statement displays the value "netscapeHomePage" in the alert dialog box, because "netscapeHomePage" is the value of the windowName argument of netscapeWin.
```netscapeWin=window.open("http://www.netscape.com", "netscapeHomePage")

```

For button, reset, and submit:

• value property

## navigator object

Contains information about the version of Navigator in use.

### Syntax

To use a navigator object:

```navigator.propertyName
```
propertyName is one of the properties listed below.

• None.

### Description

Use the navigator object to determine which version of the Navigator your users have.

### Properties

• appCodeName specifies the code name of the browser
• appName specifies the name of the browser
• appVersion specifies version information for the Navigator
• userAgent specifies the user-agent header

• None.

• None.

### Examples

See the examples for the individual properties.

• anchors object

## onBlur event handler

A blur event occurs when a select, text, or textarea field on a form loses focus. The onBlur event handler executes JavaScript code when a blur event occurs.

See the relevant objects for the onBlur syntax.

### Examples

In the following example, userName is a required text field. When a user attempts to leave the field, the onBlur event handler calls the required() function to confirm that userName has a legal value.

`<INPUT TYPE="text" VALUE="" NAME="userName" onBlur="required(this.value)">`

• onChange , onFocus event handlers

## onChange event handler

A change event occurs when a select, text, or textarea field loses focus and its value has been modified. The onChange event handler executes JavaScript code when a change event occurs.

Use the onChange event handler to validate data after it is modified by a user.

See the relevant objects for the onChange syntax.

### Examples

In the following example, userName is a text field. When a user attempts to leave the field, the onBlur event handler calls the checkValue() function to confirm that userName has a legal value.

`<INPUT TYPE="text" VALUE="" NAME="userName" onBlur="checkValue(this.value)">`

• onBlur , onFocus event handlers

## onClick event handler

A click event occurs when an object on a form is clicked. The onClick event handler executes JavaScript code when a click event occurs.

See the relevant objects for the onClick syntax.

### Examples

For example, suppose you have created a JavaScript function called compute(). You can execute the compute() function when the user clicks a button by calling the function in the onClick event handler, as follows:

`<INPUT TYPE="button" VALUE="Calculate" onClick="compute(this.form)">`

In the above example, the keyword this refers to the current object; in this case, the Calculate button. The construct this.form refers to the form containing the button.

For another example, suppose you have created a JavaScript function called pickRandomURL() that lets you select a URL at random. You can use the onClick event handler of a link to specify a value for the HREF attribute of the <A> tag dynamically, as shown in the following example:

<A HREF="" onClick="this.href=pickRandomURL()" onMouseOver="window.status='Pick a random URL'; return true"> Go!</A>

In the above example, the onMouseOver event handler specifies a custom message for the Navigator status bar when the user places the mouse pointer over the Go! anchor. As this example shows, you must return true to set the window.status property in the onMouseOver event handler.

## onFocus event handler

A focus event occurs when a field receives input focus by tabbing with the keyboard or clicking with the mouse. Selecting within a field results in a select event, not a focus event. The onFocus event handler executes JavaScript code when a focus event occurs.

See the relevant objects for the onFocus syntax.

### Examples

The following example uses an onFocus handler in the valueField textarea object to call the valueCheck() function.

`<INPUT TYPE="textarea" VALUE="" NAME="valueField" onFocus="valueCheck()">`

• onBlur , onChange event handlers

## onLoad event handler

A load event occurs when Navigator finishes loading a window or all frames within a <FRAMESET>. The onLoad event handler executes JavaScript code when a load event occurs.

Use the onLoad event handler within either the <BODY> or the <FRAMESET> tag, for example, <BODY onLoad="...">.

In a <FRAMESET> and <FRAME> relationship, an onLoad event within a frame (placed in the <BODY> tag) occurs before an onLoad event within the <FRAMESET> (placed in the <FRAMESET> tag).

### Examples

In the following example, the onLoad event handler displays a greeting message after a web page is loaded.

```<BODY onLoad="window.alert("Welcome to the Brave New World home page!")>
```

## onMouseOver event handler

A mouseOver event occurs once each time the mouse pointer moves over an object from outside that object. The onMouseOver event handler executes JavaScript code when a mouseOver event occurs.

You must return true within the event handler if you want to set the status or defaultStatus properties with the onMouseOver event handler.

See the relevant objects for the onMouseOver syntax.

### Examples

By default, the HREF value of an anchor displays in the status bar at the bottom of the Navigator when a user places the mouse pointer over the anchor. In the following example, the onMouseOver event handler provides the custom message "Click this if you dare."

<A HREF="http://home.netscape.com/" onMouseOver="window.status='Click this if you dare!'; return true"> Click me</A>

See onClick for an example of using onMouseOver when the <A> tag's HREF attribute is set dynamically.

## onSelect event handler

A select event occurs when a user selects some of the text within a text or textarea field. The onSelect event handler executes JavaScript code when a select event occurs.

See the relevant objects for the onSelect syntax.

### Examples

The following example uses an onSelect handler in the valueField text object to call the selectState() function.

`<INPUT TYPE="text" VALUE="" NAME="valueField" onSelect="selectState()">`

## onSubmit event handler

A submit event occurs when a user submits a form. The onSubmit event handler executes JavaScript code when a submit event occurs.

You can use the onSubmit event handler to prevent a form from being submitted; to do so, put a return statement that returns false in the event handler. Any other returned value lets the form submit. If you omit the return statement, the form is submitted.

See the relevant objects for the onSubmit syntax.

### Examples

In the following example, the onSubmit event handler calls the formData() function to evaluate the data being submitted. If the data is valid, the form is submitted; otherwise, the form is not submitted.

```form.onSubmit="return formData(this)"
```

See also the examples for the form object.

• submit object
• submit method

## onUnload event handler

An unload event occurs when you exit a document. The onUnload event handler executes JavaScript code when an unload event occurs.

Use the onUnload event handler within either the <BODY> or the <FRAMESET> tag, for example, <BODY onUnload="...">.

In a <FRAMESET> and <FRAME> relationship, an onUnload event within a frame (placed in the <BODY> tag) occurs before an onUnload event within the <FRAMESET> (placed in the <FRAMESET> tag).

### Examples

In the following example, the onUnload event handler calls the cleanUp() function to perform some shut down processing when the user exits a web page:

```<BODY onUnload="cleanUp()">
```

## open method (document object)

Opens a stream to collect the output of write or writeln methods.

### Syntax

`document.open(["mimeType"])`

mimeType specifies any of the following document types:

```   text/html
text/plain
image/gif
image/jpeg
image/x-bitmap
plugIn
```
plugIn is any two-part plug-in MIME type that Netscape supports.

### Description

The open method opens a stream to collect the output of write or writeln methods. If the mimeType is text or image, the stream is opened to layout; otherwise, the stream is opened to a plug-in. If a document exists in the target window, the open method clears it.

End the stream by using the document.close() method. The close method causes text or images that were sent to layout to display. After using document.close(), issue document.open() again when you want to begin another output stream.

mimeType is an optional argument that specifies the type of document to which you are writing. If you do not specify a mimeType, the open method assumes text/html by default.

Following is a description of mimeType:

• text/html specifies a document containing ASCII text with HTML formatting.
• text/plain specifies a document containing plain ASCII text with end-of-line characters to delimit displayed lines.
• image/gif specifies a document with encoded bytes constituting a GIF header and pixel data.
• image/jpeg specifies a document with encoded bytes constituting a JPEG header and pixel data.
• image/x-bitmap specifies a document with encoded bytes constituting a bitmap header and pixel data.
• plugIn loads the specified plug-in and uses it as the destination for write and writeln methods. For example, "x-world/vrml" loads the VR Scout VRML plug-in from Chaco Communications, and "application/x-director" loads the Macromedia Shockwave plug-in.

### Examples

The following function calls document.open() to open a stream before issuing a write method:
```function windowWriter1() {
var myString = "Hello, world!"
msgWindow.document.open()
msgWindow.document.write("<P>" + myString)
msgWindow.document.close()
}
```
In the following example, the probePlugIn() function determines whether a user has the Shockwave plug-in installed:
```function probePlugIn(mimeType) {
var havePlugIn = false
var tiny = window.open("", "teensy", "width=1,height=1")
if (tiny != null) {
if (tiny.document.open(mimeType) != null)
havePlugIn = true
tiny.close()
}
return havePlugIn
}

var haveShockwavePlugIn = probePlugIn("application/x-director")
```

• clear, close, write, writeln methods

## open method (window object)

Opens a new web browser window.

### Syntax

```[windowVar = ][window].open("URL", "windowName", ["windowFeatures"])
```

windowVar is the name of a new window. Use this variable when referring to a window's properties, methods, and containership.
URL specifies the URL to open in the new window. See the location object for a description of the URL components.
windowName is the window name to use in the TARGET attribute of a <FORM> or <A> tag. windowName can contain only alphanumeric or underscore (_) characters.
windowFeatures is a comma-separated list of any of the following options and values:

```   toolbar[=yes|no]|[=1|0]
location[=yes|no]|[=1|0]
directories[=yes|no]|[=1|0]
status[=yes|no]|[=1|0]
scrollbars[=yes|no]|[=1|0]
resizable[=yes|no]|[=1|0]
width=pixels
height=pixels
```

You may use any subset of these options. Separate options with a comma. Do not put spaces between the options.

pixels is a positive integer specifying the dimension in pixels.

### Description

The open method opens a new web browser window on the client, similar to choosing New Web Browser from the File menu of the Navigator. The URL argument specifies the URL contained by the new window. If URL is an empty string, a new, empty window is created.

In event handlers, you must specify window.open() instead of simply using open(). Due to the scoping of static objects in JavaScript, a call to open() without specifying an object name is equivalent to document.open().

windowFeatures is an optional, comma-separated list of options for the new window. The boolean windowFeatures options are set to true if they are specified without values, or as yes or 1. For example, open("", "messageWindow", "toolbar") and open("", "messageWindow", "toolbar=1") both set the toolbar option to true. If windowName does not specify an existing window and you do not specify windowFeatures, all boolean windowFeatures are true by default. If you specify any item in windowFeatures, all other Boolean windowFeatures are false unless you explicitly specify them.

Following is a description of the windowFeatures:

• toolbar creates the standard Navigator toolbar, with buttons such as "Back" and "Forward", if true
• location creates a Location entry field, if true
• directories creates the standard Navigator directory buttons, such as "What's New" and "What's Cool", if true
• status creates the status bar at the bottom of the window, if true
• menubar creates the menu at the top of the window, if true
• scrollbars creates horizontal and vertical scrollbars when the document grows larger than the window dimensions, if true
• resizable allows a user to resize the window, if true
• width specifies the width of the window in pixels
• height specifies the height of the window in pixels

### Examples

In the following example, the windowOpener function opens a window and uses write methods to display a message:

```function windowOpener() {
msgWindow.document.write
msgWindow.document.write
("<CENTER><BIG><B>Hello, world!</B></BIG></CENTER>")
}
```

The following is an onClick event handler that opens a new client window displaying the content specified in the file sesame.html. The window opens with the specified option settings; all other options are false because they are not specified.

<FORM NAME="myform"> <INPUT TYPE="button" NAME="Button1" VALUE="Open Sesame!" onClick="window.open ('sesame.html', 'newWin', 'scrollbars=yes,status=yes,width=300,height=300')"> </FORM>

Notice the use of single quotes (') inside the onClick event handler.

• close method

## options property

An array corresponding to options in a select object (<OPTION> tags) in source order. See select object.

## parent property

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

### Syntax

```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.

### 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.

### Examples

See the examples for the frame object.

## parse method

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

### Syntax

`Date.parse(dateString)`
dateString is a string representing a date or a property of an existing object.

### 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 syntax: "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.

### Examples

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.

### Syntax

`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".

### Examples

The following examples 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.

### Syntax

`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".

### Examples

The following examples 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 examples all return "NaN" or 0:

```parseInt("Hello", 8)
parseInt("0x7", 10)
parseInt("FFF", 10)
```

Even though the radix is specified differently, the following examples all return 17 because the input string begins with "0x".

```parseInt("0x11", 16)
parseInt("0x11", 0)
parseInt("0x11")
```

• isNaN, parseFloat functions

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

### Syntax

To define a password object, use standard HTML syntax:

```<INPUT
[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
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.

• form

### Description

A password object on a form looks as follows:

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

• focus
• blur
• select

• None.

### Examples

• form and text objects

## pathname property

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

### Syntax

```1. links[index].pathname
2. location.pathname
```

index is an integer representing a link object.

### 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.

### Examples

See the examples 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.

### Syntax

`Math.PI`

### Description

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

### Examples

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.

### Syntax

```1. links[index].port
2. location.port
```

index is an integer representing a link object.

### 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.

### Examples

See the examples for the href property.

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

## pow method

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

### Syntax

`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.

### Examples

```//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.

### Syntax

`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.

### 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.

### Examples

```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.

### Syntax

```1. links[index].protocol
2. location.protocol
```

index is an integer representing a link object.

### 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.

### Examples

See the examples for the href property.