enate = oneString + oneInt //Results in "11"
var oneAddition = oneInt + oneString //Results in 2

In the first addition statement, the first operator is a string. JavaScript assumes that the operation is to join two strings. When JavaScript encounters an integer in the second operator, it converts the variable to a string to meet its own expectations.

Since JavaScript does not maintain any methods or properties to determine the current type for a variable, it is important to monitor the use of variables closely to avoid unexpected results.



Chapter 21 -- JavaScript Reference

Chapter 21

JavaScript Reference


JavaScript syntax and commands are divided into several categories depending on their use and function.

Objects are the building blocks of JavaScript. They are used to return and modify the status of forms, pages, the browser, and programmer-defined variables. An easy way to think about an object is as a noun. Cat, car, house, computer, and form are all nouns and could all be represented as an object.

You use properties to differentiate between objects of the same class-for example, all objects that are a cat. Properties are adjectives and refer to items that might make the object different from other objects. In the cat example, this could be weight, color, breed, disposition, current activity.

You use methods to pass messages to the object and sometimes to change its properties. For example, one method could be used to change the cats current activity from eating to sleeping, whereas another could be used to change its weight from heavy to really heavy.

Following is a listing of the building blocks of JavaScript.

abs

(Method)

Returns the absolute (unsigned) value of its argument.

Math.abs(argument)
Usage

he following example returns 10 and 12.5, respectively.

 document.writeln(Math.abs(-10));
John.age.value = 12.5
document.writeln(Math.abs(John.age.value))
Related Items

Method of Math.

acos

(Method)

Returns the arc cosine (from zero to pi] radians) of its argument.

Math.acos(argument)
Usage

The argument should be a number between -1 and 1. If the value is outside the valid range, a zero is returned.

Related Items

Method of Math.

See the asin, atan, cos, sin, and tan methods.

action

(Property)

A reflection of the action attribute in an HTML <form> tag.

document.formName.action
document.forms[index].action
Usage

action returns a string consisting of a destination URL for data submitted from a form. This value can be set or changed before or after the document has been loaded and formatted.

In this example, the action for a form called outlineForm is set to the URL in the variable outlineURL.

outlineURL = "http://www.wossamottau.edu/cgi-bin/outline.cgi"
outlineForm.action=outlineURL
Related Items

Property of form.

See the encoding, method, and target properties.

alert

(Method)

Displays a JavaScript alert dialog box with an OK button and a user-defined message (see Figure 21.1).

[window.]alert(AlertMessage)

Figure 21.1: Users must click the OK button in a JavaScript alert box before they can return to the document.

Usage

Before users can continue with an operation, they must press the OK button in the alert box.

Related Items

Method of window.

See the confirm and prompt methods.

alinkColor

(Property)

The color of a link after the mouse button is pressed but before it's released.

document.alinkColor
Usage

Like all colors in JavaScript, alinkColor is expressed as a hexadecimal RGB triplet or string literal. It cannot be changed after the HTML source document is processed. Both of these examples set the color to alice blue.

document.alinkColor="aliceblue"
document.alinkColor="F0F8FF"
Related Items

Property of document.

See the bgColor, fgColor, linkColor, and vlinkColor properties.

anchors array

(Object)

An array containing information about possible targets of a hypertext link in a document.

[windowName.]document.anchors[index]
Usage

anchors array is a read-only object that is set in HTML with <A> tags.

<A [HREF=URL] NAME="anchor name" [TARGET="windowName"]>
anchor text
</A>

Including a value for HREF also makes the anchor a link and adds it to the links array. New anchors are defined with JavaScript by using the anchor method.

To determine how many anchors are included in a document, use the length property.

document.anchors.length

The value of document.anchor[index] returns null. For example, the value of document.anchor[0] returns null even though it was the first anchor created with
<A NAME="bob">All about Bob</A>.

Related Items

Property of document.

See the link object and the anchor method.

anchor

(Method)

Creates and displays an HTML hypertext target.

textString.anchor(anchorName)
Usage

Used with write or writeln methods, anchor creates an HTML anchor in the current document, where textString is what the user sees and anchorName is equivalent to the name attribute of an HTML <anchor> tag.

anchorString = "Louie's Place";
document.writeln(anchorString.anchor("louies_place")
Related Items

Method of string.

See the link method.

anchors

(Property)

An array of all defined anchors in the current document. See the anchor object for a detailed description.

document.anchors[index]
Usage

If the length of an anchor array in a document is 5, then the anchors array is represented as document.anchors[0] through document.anchors[4].

Related Items

Property of document.

See the anchor object.

See the length and links properties.

appCodeName

(Property)

Returns a read-only string with the code name of the browser.

navigator.appCodeName
Usage

To display the code name for the current browser, use the following line:

document.write("The code name of your browser is " + navigator.appCodeName + ".")

For Netscape Navigator 2.0, this returns:

The name of your browser is Mozilla.
Related Items

Property of navigator.

See the appName, appVersion, and userAgent properties.

appName

(Property)

Returns a read-only string with the name of the browser.

navigator.appName
Usage

To display the application name for the current browser, use the following line:

document.write("The name of your browser is " + navigator.appName + ".")

For Netscape Navigator 2.0, this returns:

The code name of your browser is Netscape.
Related Items

Property of navigator.

See the appCodeName, appVersion, and userAgent properties.

appVersion

(Property)

Returns a string with the browser version information.

navigator.appVersion
Usage

appVersion is used to check which browser version the client is using. It returns in the releaseNumber (platform; country) format. For a Windows 95 release of Netscape 2.0:

document.write("The version of your browser is: " + navigator.appVersion + ".")
returns
The version of your browser is: 2.0 (Win95; I).

This specifies an international release of Navigator 2.0 running on Windows 95. The U country code specifies a U.S. release, whereas an I indicates an international release.

Related Items

Property of navigator.

See the appName, appCodeName, and userAgent properties.

asin

(Method)

Returns the arc sine of its argument.

Math.asin(argument)
Usage

Passing a number between -1 and 1 to asin returns the arcsine (between -þ/2 and þ/2 radians). If the number is outside the range, a zero is returned.

Related Items

Method of Math.

See the acos, atan, cos, sin, and tan methods.

atan

(Method)

Returns the arc tangent of its argument.

Math.(argument)
Usage

atan returns a number between between -pi/2 and pi/2 radians, representing the size
of an angle in radians. Its argument is a number between -1 and 1, representing the tangent.

Related Items

Method of Math.

See the acos, asin, cos, sin, and tan methods.

back

(Method)

Recalls the previous URL from the history list.

history.back()
Usage

The usage for back is the same as for history.go(-1).

Related Items

Method of history.

See the forward and go methods.

bgColor

(Property)

The document background color.

document.bgColor
Usage

The usage for bgColor overrides the background color set in the browser preferences. It is expressed as a hexadecimal RGB triplet or string literal. It can be changed at any time. The following example allows users to use radio buttons to set their own background color.

function newColor(colorString) {
document.bgColor = colorString
}
...
<FORM NAME="colors">
<INPUT TYPE="radio" NAME="color" VALUE="F0F8FF" onClick="newColor(this.value)">Alice Blue
<INPUT TYPE="radio" NAME="color" VALUE="FF4500" onClick="newColor(this.value)">Ochre
<INPUT TYPE="radio" NAME="color" VALUE="FFEFD5" onClick="newColor(this.value)">Papaya Whip
</FORM>
Related Items

Property of document.

See the alinkColor, fgColor, linkColor, and vlinkColor properties.

big

(Method)

Formats a string object as a big font.

stringName.big()
Usage

Functionally, the usage for big is the same as encasing text with HTML <BIG> tags. Both of the following examples result in the same output: displaying the message "Welcome to my home page" in a big font:

var welcomeMessage = "Welcome to my home page."
document.write(welcomeMessage.big())

<BIG> Welcome to my home page.</BIG>
Related Items

Method of string.

See the fontsize and small methods.

blink

(Method)

Formats a string object as a blinking line.

stringname.blink()
Usage

The usage for blink same as encasing text with HTML <BLINK> tags. Both of the following examples produce a flashing line that says "Notice:"

var attentionMessage = "Notice"
document.write(attentionMessage.blink())

<BLINK>Notice</BLINK>
Related Items

Method of string.

See the bold, italics, and strike methods.

blur

(Method)

Removes focus from the specified form element.

document.formName.elementName.blur()
document.forms[index].elements[index].blur()
Usage

For example, the following line removes focus from the feedback element:

feedback.blur()

assuming that feedback is defined as:

<INPUT TYPE="text" NAME="feedback">
Related Items

Method of password, select, text, and textarea.

See the focus and select methods.

bold

(Method)

Formats a string object in bold text.

stringName.bold()
Usage

The usage for bold is same as encasing text with HTML <B> tags.

Related Items

Method of string.

See the blink, italics, and strike methods.

button

(Object)

A pushbutton on a form.

formName.buttonName
forms[index].elements[index]
Usage

Buttons must be defined within a <FORM> tag and can be used to perform an action.

<INPUT TYPE="button" NAME="buttonName" VALUE="textOnButton" [onClick="eventHandler"]>

When accessed from within a form, the form name is understood. To avoid confusion and create clearer code, it's preferred to use the form name with form elements. Used with an onClick event handler, a button becomes a custom item that can initiate events and activities beyond the basic submit and reset.

The following button invokes the validateForm function when the button is pressed.

<INPUT TYPE="button" NAME="validate" VALUE="Check for Accuracy" onClick="validateForm(this.form)">
Related Items

Property of form.

See the reset and submit objects.

See the name and value properties.

See the click method.

See the onClick event handler.

ceil

(Method)

Returns the next integer larger than the argument.

Math.ceil(argument)
Usage

ceil returns the smallest integer greater than or equal to the integer or floating-point decimal passed to it as an argument. For example:

Math.ceil(1.01)

returns a 2.

Related Items

Method of Math.

See the floor method.

charAt

(Method)

Returns a character from a string.

stringName.charAt(index)
Usage

This method accepts an index as its argument and returns the character at that position in the string. The first character is at position 0 and the last at length -1.

var userName = "Bobba Louie"
document.write(userName.charAt(4))

returns an "a."

Related Items

Method of string.

See the indexOf and lastIndexOf methods.

checkbox

(Object)

A form element that the user sets to on or off by clicking it.

formName.checkboxName
forms[index].elements[index]
Usage

checkboxes are defined within a <FORM> tag.

<INPUT TYPE="checkbox" NAME="checkboxName" VALUE="checkboxValue"
[CHECKED] [onClick="eventHandler"]> textToDisplay

The properties and methods of checkboxes are used in a variety of ways.

Use the checked value of checkbox to see if it is currently selected (true) or not (false). If the CHECKED option is used as part of the definition, defaultChecked also returns true.

Related Items

Property of form.

See the radio object.

See the checked, defaultChecked, name, and value properties.

See the click method.

See the onClick event handler.

checked

(Property)

Returns a Boolean flag representing an individual checkbox or radio button status.

formName.checkboxName.checked
formName.radioButtonName[index].checked
forms[index].elements[index].checked
Usage

checked returns a Boolean value (true or false) indicating whether a checkbox or radio button is selected. The value is updated immediately when an item is checked. Used with the for...in statement, it can check the status of buttons:

function whichOneChecked() {
var checkedValue = ""
for (var i in document.formName.radioName) {
      if (document.formName.radioName[i].checked==true)
         checkedValue=document.formName.radioName[i].value
}
}
Related Items

Property of checkbox and radio.

See the defaultChecked property.

clear

(Method)

Clears window contents, as a clear screen does.

document.clear()
Usage

clear erases the contents of a window, regardless of how the window was filled.

Related Items

Method of document.

See the close, open, write, and writeln methods.

clearTimeout

(Method)

Cancels a timeout.

[windowName.]clearTimeout(argument)
parent.[frameName.]clearTimeout(argument)
Usage

clearTimeout removes a timeout that was previously set using the setTimeout method. A timeout is set using a unique timeout ID that must be used to clear it:

clearTimeout(waitTime)
Related Items

Method of frame and window.

See the setTimeout method.

click

(Method)

Simulates a mouse click.

formName.elementName.click()
forms[index].elements[index].click()
Usage

The effect of a click depends on the type of form element that is referenced.

Table 21.1  The Click Method and its Effect on Form Elements

Form Element Action
Button, Reset, and Submit Same as clicking button
Radio Selects radio button
Checkbox Marks checkbox and sets value to on

Related Items

Method of button, checkbox, radio, reset, and submit.

close

(Method)

For a document object, closes the current stream of output and forces its display.

For a window object, closes the current window.

document.close()
window.close()
[windowName.]close()
Usage

For documents, close stops the winsock browser's animation and displays "Document: Done" in the status bar.

For windows, as with all window commands, the window object is assumed. For example:

window.close()
close()
self.close()

all close the current window.

Related Items

Method of document and window.

See the clear, open, write, and writeln methods.

confirm

(Method)

Displays a JavaScript confirmation dialog box (see Figure 21.2).

window.confirm()
[windowName.]confirm()

Figure 21.2: The JavaScript confirmation box allows a user to continue or to cancel out of an operation.

Usage

Similar to an alert with the addition of a Cancel button, confirm displays a message and a button to continue. confirm returns a true if the user selects OK and a false for Cancel. The following example loads a new window if the user presses OK:

if (confirm("Are you sure you want to enter.") {
   tourWindow = window.open("http:\\www.haunted.com\","hauntedhouse")
}
Related Items

Method of window.

See the alert and prompt methods.

cookie

(Property)

String value of a small piece of information stored by Navigator in a client-side cookies.txt file.

document.cookie
Usage

The value stored in the cookie is found using substring charAt, IndexOf, and lastIndexOf.

The cookie is a special property containing state/status information about the client that can be accessed by the server. Included in that state is a description of the range of URLs for which that state is valid.

Future HTTP requests from the client falling within a range of URLs described within the state object will include transmission of the current value of the state object from the client back to the server.

This simple form of data storage allows the server to provide personalized service to the client. Online merchants can store information about items currently in an electronic shopping basket, services can post registration information and automate functions such as typing a user ID.

User preferences can be saved on the client and retrieved by the server when the site is contacted. For limited-use information such as shopping services, you can also set a time limit on the life of the cookie information.

To post and view cookie settings within an HTML script, assign a value to the property.

document.cookie = "string"

CGI scripts are also used to set and retrieve cookie values. Generating the cookie requires sending an HTTP header in the format:

Set-Cookie: NAME=Value; [EXPIRES=date;] [PATH=pathname;] [DOMAIN=domainname;] [SECURE]

When a request for cookie information is made, the list of cookie information is searched for all URLs that match the current URL. Any matches are returned in this format:

cookie: NAME1=string1; NAME2=string2; ...

Cookie was an arbitrarily assigned name. For more information about the cookie and its function, see Netscape's Cookie Specification at http://home.netscape.com/newsref/std/cookie_spec.html.

Related Items

Property of document.

See the hidden object.

cos

(Method)

Returns the cosine of the argument.

Math.cos(argument)
Usage

Angle size must be expressed in radians and the result is from -1 to 1.

Related Items

Method of Math.

See the acos, asin, atan, sin, and tan methods.

Date

(Object)

Provides a set of methods for working with dates and times.

Date.method(parameters)
Usage

The built-in Date object replaces a normal date type. Although it does not have any properties, the built-in Date object is equipped with a range of methods to set and change the values of its values.

Although date values are returned in standard form and syntax, the actual value is stored as the number of milliseconds since midnight on 1/1/70. The use of this convention prohibits the use of dates before 1/1/70.

To create a new Date object, use one of the following syntax conventions:

objectName = new Date() //Creates object with current date and time
objectName = new Date("month day, year [hours:minutes:seconds]")
//Creates date object with date and time values in string variable or constant
objectName = new Date(year, month, day [, hours, minutes, seconds])
//Creates date object with integer values

If you omit the time component when you create a Date object, it defaults to midnight (00:00:00). Methods for getting and setting time and date information are divided into four classes: set, get, to, and parse/UTC.

Except for the day of the month, all numerical representations of date components begin numbering with 0. This should not present a problem except with months, which are represented by 0 (January) through 11 (December).

The standard date syntax is "Thu, 11 Jan 1996 06:20:00 GMT". U.S. time zone abbreviations are also understood; but for universal use, specify the time zone offset. For example, "Thu, 11 Jan 1996 06:20:00 GMT+0530" is a place 5 hours and 30 minutes west of the Greenwich meridian.

Related Items

See the getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toLocaleString, and toUTC methods.

defaultChecked

(Property)

A Boolean value (true or false) indicating whether a checkbox or radio button is checked by default.

formName.elementName.defaultChecked
forms[index].elements[index].defaultChecked
Usage

Setting a value to defaultChecked can override the checked attribute of a form element. The following section of code resets a group of radio buttons to their original state by finding and setting the default button:

for (var i in menuForm.choices) {
   if (menuForm.choices[i].defaultChecked) {
      menuForm.choices[i].defaultChecked = true
}
}

The button display is not affected with a change in the defaultChecked even if the status of other buttons are affected.

Related Items

Property of checkbox and radio.

See the form object.

See the checked property.

defaultSelected

(Property)

Default state of an item in a form select element.

formName.elementName.defaultSelected
forms[index].elements[index].defaultSelected
Usage

defaultSelected returns a true or a false, depending on whether or not the CHECKED option was used with a select form element. Setting a value with this property can override the selected attribute of an <option> tag. The syntax and behavior are identical to those of defaultChecked.

Related Items

Property of options.

See the index, selected, and selectedIndex properties.

defaultStatus

(Property)

The default message displayed in the status bar at the bottom of a Navigator window (see Figure 21.3).

[windowName.]defaultStatus
Usage

Sets the message in the status bar when nothing else is displayed. This is preempted by a priority or transient message such as a mouseOver event with an anchor. For example:

window.defaultStatus = "Welcome to my home page"

displays the welcome message while the mouse is not over a link or Netscape is not performing an action that it needs to notify the user about.

Related Items

Property of window.

Figure 21.3: The window status bar, which can hold predefined text other than a link URL.

See the status property.

defaultValue

(Property)

The initial contents of text-type form elements.

formName.elementName.defaultValue
forms[index].elements[index].defaultValue
Usage

For any of the standard HTML text form fields-hidden, password, text, textarea (between the <TEXTAREA> tags), and string-defaultValue returns the initial contents, regardless of the current value. For password elements, this property is initially set to null for security reasons, regardless of any set value.

Related Items

Property of hidden, password, text, and textarea.

See the value property.

document

(Object)

An object created by Navigator when a page is loaded.

document.propertyOrMethod
document.objectName.propertyOrMethod
Usage

document is one of the base objects of JavaScript and contains information on the current document such as title, background color, and forms. These properties are defined within <body> tags. Through write and writeln, document also provides methods for displaying HTML text to the user.

You can reference the anchors, forms, and links of a document by using the appropriate arrays of the document object. These arrays contain an entry for each anchor, form, or link in a document.

Related Items

Property of window.

See the frame object.

See the alinkColor, anchors, bgColor, cookie, fgColor, forms, lastModified, linkColor, links, location, referrer, title, and vlinkColor properties.

See the clear, close, open, write, and writeln methods.

See the onLoad and onUnload event handlers.

E

(Property)

The base of natural logarithms.

Math.E
Usage

Also called Euler's constant, this value is approximately 2.71828.

Related Items

Property of Math.

See the LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, and SQRT2 properties.

elements array

(Object)

An array of form elements in source order.

formName.elements[index]
forms[index].elements[index]
Usage

All elements of a form are included in this array, which is accessible through the form name or the forms array. Form elements include buttons, checkboxes, radio buttons, text, and textarea objects. The elements can be referenced by their index.

For example, if a form contains two text fields, three radio buttons, and two push buttons, they are referenced in the elements array as formName.elements[0] through formName.elements[6]. Note that numbering begins with 0 and not 1.

To find the number of elements in a form, use the length property. The value of a member of the element array is the complete HTML text used to create it.

Elements can also be referenced by the element name. For example, a password element called newPassword is the second form element on an HTML page. Its value is accessed in three ways:

formName.elements[1].value
formName.elements["newPassword"].value
formName.newPassword.value

Values cannot be set or changed using the read-only elements array.

Related Items

Property of form.

See the length property.

elements

(Property)

An array of objects containing form elements in HTML source order.

formName.elements[index]
forms[index].elements[index]
Usage

The array index begins with 0 and ends with the number of form elements -1. For a complete discussion on elements, see the elements object.

Related Items

Property of form.

See the elements object.

encoding

(Property)

Returns a string reflecting the MIME encoding type.

formName.encoding
forms[index].encoding
Usage

MIME encoding types are set in the enctype attribute of an HTML <FORM> tag. The standards for MIME encoding in HTML are not established, but progress and draft documents are located at the University of California-Irvine Information and Computer Sciences Department, found on the Web at http://www.ics.uci.edu/pub/ietf/html/.

Related Items

Property of form.

See the action, method, and target properties.

escape*

(Method)

Returns the ASCII code of its argument.

escape(argument)
Usage

HTML ASCII codes are based on the ISO Latin -1 character set in the form %xxx where xxx is the decimal ASCII code. This method is not associated with any other object but is actually a native part of the JavaScript language. Alphanumeric characters (letters and numbers) will return as themselves, while symbols are returned as their ASCII code.

document.write(escape("Hi!"))
returns
Hi%21
Related Items

See the unescape method.

eval*

(Method)

Evaluates a string as a numeric expression.

eval(string)
Usage

This built-in function takes a string or numeric expression as its argument. If a string, eval tries to convert it to a numeric expression, then evaluates the expression and returns the value.

var x = 10
var y = 20
document.write(eval("x + y"))

This method can also be used to perform JavaScript commands included as part of a string.

var doThis = "if (x==10) { alert('Your maximum has been reached') }
function checkMax () {
   x++;
   eval(doThis)
}

This can be useful when converting a date from a form (always a string) into a numerical expression or number.

exp

(Method)

Returns a natural logarithm.

Math.exp(argument)
Usage

exp returns the argument raised to the power of E (Euler's constant) to compute a natural logarithm.

Related Items

Method of Math.

See the log and pow methods.

See the E property.

fgColor

(Property)

The color of foreground text.

document.fgColor
Usage

Colors in JavaScript are represented as a hexadecimal RGB triplet or a sting literal. This value cannot be changed after a document is processed, although it can be changed for individual sections of text with the fontcolor method.

fgColor takes two forms:

document.fgColor="aliceblue"
document.fgColor="F0F8FF"
which has the same effect as the TEXT attribute in the <BODY> tag:
<BODY TEXT="aliceblue">
Related Items

Property of document.

See the alinkColor, bgColor, linkColor, and vlinkColor properties.

See the fontcolor method.

fixed

(Method)

Formats the calling string into a fixed-pitch font.

stringName.fixed()
Usage

Using fixed is identical to encasing a string argument in HTML <tt> tags.

Related Items

Method of string.

floor

(Method)

Returns the next integer smaller than the argument.

Math.floor(argument)
Usage

Passing an integer or floating-point decimal to this method returns an integer less than or equal to its argument. For example:

Math.floor(2.99)
returns a 2.

Related Items

Method of Math.

See the ceil method.

focus

(Method)

Gives focus to a specific form element.

formName.elementName.focus()
forms[index].elements[index].focus()
Usage

Using the name of the form and the element, focus gives the element focus. From that point, a value can be entered by JavaScript commands or the user can complete the
entry.

Related Items

Method of password, select, text, and textarea.

See the blur and select methods.

fontcolor

(Method)

Overrides the default foreground color for a string object.

stringName.fontcolor()
Usage

fontcolor formats the string object to a specific color expressed in the argument as a hexadecimal RGB triplet or a string literal. Using fontcolor is like using <FONT COLOR=COLOR>.

myDog = "Brown";
document.write(myDog.fontcolor("sienna"))
Related Items

Method of string.

fontsize

(Method)

Formats the string object to a specific font size.

stringName.fontsize(argument)
Usage

This method uses one of seven defined sizes using an integer through the <FONTSIZE=SIZE> tag. If a string is passed, then the size is changed relative to the value set in the <BASEFONT> tag.

The argument represents the size. If it is an integer, it is the size of the font and must be a number ranging from 1 to 7. If it is a string, it changes the size of the font relative to the base font.

Related Items

Method of string.

See the big and small methods.

form (forms array)

(Object)

An object representing a form on a page.

document.formName
document.forms[index]
Usage

form is a property of the document object. Each form in a document is a separate and distinct object that can be referenced using the name of the form as the form object. The form object is also represented as an array created as forms are defined through HTML tags.

If the first form in a document is named orderForm, then it could be referenced as document.orderForm or document.forms[0]. If no name is given to the form, it can only be referenced by its index in the forms array. The number of individual forms on a page is available by using the length property.

document.forms.length

Individual elements of the form are referenced by their name or by using the elements array.

document.formName.elements[index]

The forms array is a read-only object. Attempts to set the value through statements
such as:

document.forms[1]="OldGuestBook"

have no effect.

The value of an item in the forms array is presented in syntax similar to the syntax of HTML tags. For example, the value of the form object for a form with the name userInfo is <object userInfo>.

Related Items

Property of document.

See the hidden object, the action, elements, encoding, forms, method, name, and target properties.

See the submit method.

See the onSubmit event handler.

forms

(Property)

An array of objects corresponding to named forms in HTML source order.

document.forms
Usage

forms are a property of the document object and contain an entry for each form object in a document. For a detailed discussion, see the form object.

Related Items

Property of document.

See the form object.

See the length property.

forward

(Method)

Loads the next document on the URL history list.

history.forward()
Usage

This method is the same as history.go(1).

Related Items

Method of history.

See the back and go methods.

frame

(Object)

A window containing HTML subdocuments that are independently scrollable.

[windowName.][parent.]frameName
[windowName.][parent.]frames[index]
Usage

Frames can point to different URLs and be targeted by other frames-all in the same window. Each frame is a window object defined using the <frameset> tag to define the layout that makes up the page. The page is defined from a parent HTML document. All subdocuments are children of the parent.

If a frame contains definitions for SRC and NAME attributes, then the frame can be identified from a sibling by using the parent object as parent.frameName or parent.frames[index].

Related Items

Property of window.

See the document and window objects.

See the defaultStatus, frames, parent, self, status, top, and window properties.

See the setTimeout and clearTimeout methods.

frames

(Property)

An array corresponding to child frame windows created using the <frameset> tag.

[windowName.][parent.]frameName
[windowName.][parent.]frames[index]
Usage

To obtain the number of child frames in a window, use the length property. For more information on the frames array, see the frame object.

Related Items

Property of window.

See the frame object.

See the length property.

getDate

(Method)

Returns the day of the month.

Date.getDate()
Usage

One of the few items in JavaScript that doesn't begin with a 0, this method returns a number between 1 and 31 representing the day of the month.

endOfTheWorld = new Date("January 11, 1996 06:18:00")
document.write(endOfTheWorld.getDate()) //Returns 11
Related Items

Method of Date.

See the setDate method.

getDay

(Method)

Returns the day of the week as an integer from 0 (Sunday) to 6 (Saturday).

Date.getDay()
dateName.getDay()
Usage

There is no corresponding setDay command because the day is automatically computed when the date value is assigned.

Related Items

Method of Date.

getHours

(Method)

Returns the hour of the day.

Date.getHours()
dateName.getHours()
Usage

The value is returned in 24-hour format, from 0 (midnight) to 23 (11 PM).

Related Items

Method of Date.

See the setHours method.

getMinutes

(Method)

Returns the minutes with an integer from 0 to 59.

Date.getMinutes()
dateName.getMinutes()
Usage

Like the other date functions, getMinutes is a straightforward matter of returning one element of the time.

endOfTheWorld = new Date("January 11, 1996 06:18:00")
document.write(endOfTheWorld.getMinutes()) //Returns 18
Related Items

Method of Date.

See the setMinutes method.

getMonth

(Method)

Returns the month of the year.

Math.getMonth()
dateName.getMonth()
Usage

The month is returned as an integer between 0 (January) and 11 (December), not as a string. The value can be confusing since it doesn't follow conventional numbering for months of the year. When sending the value to the screen or prompting it from the user, be sure to make the conversion.

function toReality() { //converts month to 1-12 numbering system
this += 1
}

function toConvention() { //converts month to 0-11 numbering system
this -= 1
}
Related Items

Method of Date.

See the setMonth method.

getSeconds

(Method)

Returns the seconds.

Date.getSeconds()
dateName.getSeconds()
Usage

Seconds are returned as an integer from 0 to 59.

Related Items

Method of Date.

See the setSeconds method.

getTime

(Method)

Returns an integer representing the current value of the date object.

Date.getTime()
dateName.getTime()
Usage

The value is the number of milliseconds since midnight, Jan. 1, 1970. This value can be used to compare the length of time between two date values.

For functions involving computation of dates, it is useful to create a set of variables defining minutes, hours, and days in milliseconds:

var dayMillisec = 1000 * 60 * 60 * 24 //1,000 milliseconds x 60 sec x 60 min x 24 hrs
var hourMillisec = 1000 * 60 * 60 //1,000 milliseconds x 60 sec x 60 min
var minuteMillisec = 1000 * 60 //1,000 milliseconds x 60 sec
Related Items

Method of Date.

See the setTime method.

getTimezoneOffset

(Method)

Returns the difference in minutes between the client machine and Greenwich mean time (GMT).

Date.getTimezoneOffset()
dateName.getTimezoneOffset()
Usage

This value is a constant except for daylight savings time.

Related Items

Method of Date.

getYear

(Method)

Returns the year of the date object minus 1900.

Date.getYear()
dateName.getYear()
Usage

Although the year can be passed to a date object as a 4-digit number in a string, the value is returned from getYear as a 2-digit number. For example, 1996 is returned as 96.

Related Items

Method of Date.

See the setYear method.

go

(Method)

Loads a document specified in the history list.

history.go(argumentOrURL)
Usage

This method can reference documents in the history list by URL or relative to the current position on the list. If the URL is incomplete, then the closest match is used. The search is not case-sensitive.

Related Items

Method of history.

See the back and forward methods.

hash

(Property)

Returns a string with the portion of a URL beginning with a hash mark (#).

document.linkName.hash
document.links[index].hash
document.location.hash
Usage

Hashes denote an anchor name fragment. They can be used to set a hash property, although it is safest to set the entire URL as a href property. An error is returned if the hash isn't found in the current location.

Related Items

Property of link and location.

See the anchor object.

See the host, hostname, href, pathname, port, protocol, and search properties.

hidden

(Object)

A text object suppressed from appearing on an HTML form.

document.formName.hiddenName
document.forms[index].elements[index].propertyOrMethod
Usage

The hidden object can be used in addition to cookies to pass name/value pairs for client/server communication. The difference between the two is that cookies are persistent on the client between session, whereas the hidden object is specific to the form.

The initial contents of the hidden object can be changed within a function by assigning new contents to its value property.

<INPUT TYPE="hidden" NAME="failedTries" VALUE="0">
... statements ...
function setRetry() {
document.userPasswordForm.failedTries.value++
}

Each time the setRetry function is called, the value of the hidden object named failedTries is incremented by 1. This is also an example of the loose typecasting in JavaScript. Even though the value is initially a string, when the script sees the mathematical operator, it attempts to convert the value to an integer.

Related Items

Property of form.

See the cookie, defaultValue, name, and value properties.

history

(Object)

A list of previously visited URLs, identical to the browser's Go menu.

document.history
Usage

This object is derived from the Go menu and contains the URL information for previously visited pages. Its methods are used to navigate to any point on the list.

To determine the number of items on the list, use the length property:

document.history.length

Navigation is possible with relative movements on the list using the forward and back methods, similar to using the menu bar navigation buttons.

document.history.forward()
document.history.back()

The go method allows jumps on the list beyond simple forward and back movement, similar to selecting an address directly from the Go menu.

document.history.go(-2) //loads the page two links ago

When you specify a window, the navigation in other windows or frames is controllable. The following example loads a new page from the history list in the content frame. Note that the name of the frame replaces the document notation.

parent.content.history.back() //loads the previous page in the frame
Related Items

Property of document.

See the location object.

See the length property.

See the back, forward, and go methods.

host

(Property)

Returns a string formed by combining the hostname and port properties of a URL:

location.host
linkName.host
links[index].host
Usage

Provides a method for viewing and changing URL host properties of location-type objects. If a port is not specified, the host property is the same as the hostname property.

location.host = "www.montana.com:80"
Related Items

Property of link and location.

See the hash, hostname, href, pathname, port, protocol, and search properties.

hostname

(Property)

Returns or changes a string with the domain name or IP address of a URL.

location.hostname
linkName.hostname
links[index].hostname
Usage

This property is similar to the host property except that it doesn't include the port information. When the port property is null, the host and hostname properties are identical.

Although hostname can be changed at any time, it is recommended to change the entire URL at once. If the hostname can't be found, an error is returned.

Related Items

Property of link and location.

See the hash, host, href, pathname, port, protocol, and search properties.

href

(Property)

Returns a string with the entire URL of the current document.

location.href
linkName.href
links[index].href
Usage

All other location and link properties are substrings of href, which can be changed at any time.

The URL of the current document is reflected to the screen using document.write.

document.write("You are here: " + window.location.href)
Related Items

Property of link and location.

See the hash, host, hostname, pathname, port, protocol, and search properties.

index

(Property)

Returns the index of a select element option.

formName.selectName.options[index].index
forms[index].elements[index].options[index].index
Usage

The position of the option in the select object, with numbering beginning at 0.

Related Items

Property of select (options array).

See the defaultSelected, selected, and selectedIndex properties.

indexOf

(Method)

Returns the location of a specific character or string.

stringName.indexOf(character|string, startingPoint)
Usage

The search starts from a specific location. The first character of the string is specified as zero and the last is the string's length -1. If the string is not found, the method returns
a -1.

The startingPoint is zero by default.

if (navigator.appVersion.indexOf('Unix') != -1)
return true
Related Items

Method of string.

See the charAt and lastIndexof methods.

isNaN*

(Method)

Checks to see if an argument is not a number.

isNaN(argument)
Usage

For UNIX platforms only, this stand-alone function returns true if the argument is not a number. On all platforms except Windows, the parseFloat and parseInt return NaN when the argument is not a number.

Related Items

See the parseFloat and parseInt methods.

italics

(Method)

Formats a string object into italics.

stringName.italics()
Usage

italics are the same as encasing a string in HTML <I> tags.

Related Items

Method of string.

See the blink, bold, and strike methods.

lastIndexOf

(Method)

Returns the index of a character or string in a string by searching from the end.

stringName.lastIndexOf()
Usage

Returns the index of a character or string in a string object by looking backwards from the end of the string or a user-specified index. It returns a -1 if the string is not found.

if (navigator.appVersion.lastIndexOf('Win') != -1)
return true
Related Items

Method of string.

See the charAt and indexOf methods.

lastModified

(Property)

A read-only string containing the date that the current document was last changed.

document.lastModified
Usage

This property is based on the attributes of the source file. The string is formatted in the standard form used by JavaScript (see the Date object). A common usage is:

dateModified = "This page last modified on " + document.lastModified
document.write(dateModified.small())
Related Items

Property of document.

length

(Property)

An integer reflecting a length- or size-related property of an object.

formName.length
forms.length
formName.elements.length
forms[index].length
[windowName.]frameName.length
frameRef.frames.length
history.length
radioName.length
selectName.length
selectName.options.length
stringName.length
windowName.length
anchors.length
links.length
Usage

The meaning of the value returned by length is determined by the array or object to which it's applied (see Table 21.2).

Table 21.2  Length Property Results

Object/ArrayProperty Measured
history Length of the history list
string Integer length of the string; zero for a null string
radio Number of radio buttons
anchors, forms, frames, links, options Number of elements in the array

Related Items

Property of anchors, elements, forms, frame, frames, history, links, options, radio, string, and window.

link (links array)

(Object)

Text or an image defined as a hypertext link to another URL.

document.linkName
document.links[index]
Usage

A link is a location object and, as such, has the same properties and methods as a location object.

If a name is defined for the object, it is also defined as an anchor and given an entry in the anchors array.

<A HREF='http://www.cnet.com/'>c|net's front door</A>
<A HREF='http://www.cnet.com/' NAME='cnet'>c|net's front door</A>

In the previous example, the first line only creates an entry in the links array. With the addition of the NAME attribute, an additional entry is created in the anchors array.

The link object is read-only. To create a new hypertext link, use the link method (method of string).

Related Items

Property of document.

See the anchor object.

See the hash, host, hostname, href, length, pathname, port, protocol, search, and target properties.

See the link method.

See the onClick and onMouseOver event handlers.

link

(Method)

Creates a hypertext link to another URL.

stringName.link(argument)
Usage

Creates a new hyperlink by defining the <HREF> attribute and the text representing the link to the user.

linkText = "Wossamatta University";
linkURL = "http://www.wossammotta.edu/";
document.write("Rocky's alma mater is " + linkText.link(linkURL))
Related Items

Method of string.

See the anchor method.

linkColor

(Property)

The hyperlink color displayed in the document.

document.linkColor
Usage

Colors are expressed as a hexadecimal RGB triplet or as a string literal. The color corresponds to the link attribute in the HTML <BODY> tag and cannot be changed after the document is processed.

document.write("The current link color is " + document.linkColor)
Related Items

Property of document.

See the alinkColor, bgColor, fgColor, and vlinkColor properties.

links

(Property)

An array representing link objects.

document.links[index]
Usage

Links are defined in HTML using <A HREF=URL> tags. These are reflected in the links property with the first link identified as document.links[0]. For a more detailed description, see the link object.

Related Items

See the link object.

See the anchors and length properties.

LN2

(Property)

A constant representing the natural logarithm of 2.

Math.LN2
Usage

This value is approximately 0.69315.

Related Items

Property of Math.

See the E, LN10, LOG2E, LOG10E, PI, SQRT1_2, and SQRT2 properties.

LN10

(Property)

A constant representing the natural logarithm of 10.

Math.LN10
Usage

This value is approximately 2.30259.

Related Items

Property of Math.

See the E, LN2, LOG2E, LOG10E, PI, SQRT1_2, and SQRT2 properties.

location

(Object)

Complete URL information for the current document.

[WindowName.][frameName.]location.propertyName
parent.[frameName.]location.propertyName
Usage

location is used to determine the URL for any active document, including those in other browser windows or frames. If the window object is omitted, the current window is assumed.

Each property of location contains a different portion of the URL. There are six parts of the URL reflected in the location object:

protocol://hostname:port/pathname search#hash

Protocols include the initial portion of the address (http, mailto, ftp, etc.) up to and including the colon. Several additional protocols are included for JavaScript.

The javascript protocol evaluates the expression after the colon and tries to load the string value of its result. If there is no result or it is undefined, the current page remains.

javascript:parent.content.history.go(-1)

The about protocol provides three methods to view information about the browser. By itself, it is the same as selecting Help, About. The other two methods, cache and plugins, reflect the current status of the cache and information about installed plug-in applications.

about:cache
about:plugins

Don't confuse this object, which is a property of window, with the location property of document. Generally, they reflect the same value but the property can't be changed, whereas the properties of the object can be changed.

Related Items

Property of window.

See the history object.

See the hash, host, hostname, href, location, pathname, port, protocol, search, and target properties.

location

(Property)

Returns a string with the URL of the current document.

document.location
Usage

This read-only property (document.location) is different from the location object properties (window.location.propertyName), which can be changed.

Related Items

Property of document.

See the location object.

log

(Method)

Returns the natural logarithm (base E) of a positive numeric expression greater than 0.

Math.log(expression)
Usage

An out-of-range number always returns -1.797693134862316e+308.

Related Items

Method of Math.

See the exp and pow methods.

LOG2E

(Property)

A constant representing the base-2 logarithm of E.

Math.LOG2E
Usage

The value is approximately 1.44270.

Related Items

Property of Math.

See the E, LN2, LN10, LOG10E, PI, SQRT1_2, and SQRT2 properties.

LOG10E

(Property)

A constant representing the base-10 logarithm of E.

Math.LOG10E
Usage

The value is approximately .43429.

Related Items

Property of Math.

See the E, LN2, LN10, LOG2E, SQRT1_2, and SQRT2 properties.

Math

(Object)

A built-in object providing constants and mathematical functions.

Math.property
Math.method(arguments)
Usage

The Math object is divided into two parts-properties containing constants and methods for implementing functions. For example, to access the value of pi in an equation, use:

Math.PI

Standard trigonometric, logarithmic, and exponential functions are also included. All arguments in trigonometric functions are limited to radians. Several comparison operations are provided, such as max for determining the greater of two numbers.

Because the purpose of the Math object is to provide a vehicle for math operations, there are no provisions for a constructor to create a duplicate math object.

For functions needing extensive use of JavaScripts math functions and constants, it is tedious to include Math as part of each equation. The with statement simplifies the syntax for this type of situation. Note the difference in the following to sections of code. Both perform the same operations.

function Hard() {
circleArea = Math.PI*(radius^2);
radians = (degrees/360)*Math.PI;
result = Math.cos(radians);
}
function Easy() {
with Math {
circleArea = PI*(radius^2);
radians = (degrees/360)*PI;
result = cos(radians);
   }
}
Related Items

See the E, LN10, LN2, PI, SQRT1_2, and SQRT2 properties.

See the abs, acos, asin, atan, ceil, cos, exp, floor, log, max, min, pow, random, round, sin, sqrt, and tan methods.

max

(Method)

Returns the greater of its two arguments.

Math.max(argument1, argument2)
Usage

Can accept any combination of numeric literals or variables, and returns the value of the largest. For example:

firstNum = 1
secondNum = 100
Math.max(firstNum,secondNum)
returns 100.

Related Items

Method of Math.

See the min method.

method

(Property)

Reflects the method attribute of an HTML <FORM> tag.

formName.method
forms[index].method
Usage

The returned value is either get or post. It can be set to a new value at any time.

The first function returns the current value of the form object, whereas the second function sets the method to the contents of newMethod.

function getMethod(formObj) {
   return formObj.method
}

function setMethod(formObj,newMethod) {
   formObj.method = newMethod
}
Related Items

Property of form.

See the action, encoding, and target properties.

min

(Method)

Returns the lesser of its two arguments.

Math.min(argument1, argument2)
Usage

Can accept any combination of literals and variables as its argument, and returns the smaller number. For example:

firstNum = 1
secondNum = 100
Math.min(firstNum,secondNum)
returns 1.

Related Items

Method of Math.

See the max method.

name

(Property)

Returns a string with the name attribute of the object.

objectName.name
frameRef.name
frameRef.frames.name
radioName[index].name
selectName.options.name
windowRef.name
windowRef.frames.name
Usage

The attribute of this property depends on the object it is applied to. It can be changed at any time.

This property refers to the internal name for the button, reset, and submit objects, not the on-screen label.

For example, after opening a new window with:

indexOutline = window.open("http://www.wossamotta.com/outline.html","MenuPage")

and issuing the command

document.write(indexOutline.name)

JavaScript returns MenuPage, which was specified as the name attribute.

For radio buttons, the name is the same for each button in the group, whereas individual buttons are identified by their position in the index.

Related Items

Property of button, checkbox, frame, password, radio, reset, select, submit, text, textarea, and window.

See the value property.

navigator

(Object)

Contains information on the client's current browser.

navigator
Usage

The navigator object returns version information about the browser, such as version number, name, and user-agent header. One common use is to determine the type of platform in use by the client so browser-specific features, such as newline characters and random numbers, are correctly used.

function UnixMachine() {
if (navigator.appVersion.lastIndexOf('Unix') != -1)
return true
else
return false
}
Related Items

See the link and anchors objects.

See the appName, appCodeName, appVersion, and userAgent properties.

onBlur

(Event Handler)

Occurs when a select, text, or textarea form element loses focus.

<INPUT TYPE="elementType" onBlur="function">
Usage

A blur event can check input as a user leaves the element. This is different from onChange, which only occurs if the contents of the field have changed.

<INPUT TYPE="textarea" VALUE="" NAME="feedback" onBlur="checkSignature(this.value)">
Related Items

Event handler of select, text, textarea.

See the focus and blur methods.

See the onChange and onFocus event handlers.

onChange

(Event Handler)

Occurs when the value of a select, text, or textarea form element changes and loses focus.

<INPUT TYPE="elementType" onChange="function">
Usage

This event is especially useful for validating user form input.

<INPUT TYPE="text" VALUE="MT" NAME="state" onChange="checkAvailability(this.value)">
Related Items

Event handler of select, text, textarea.

See the onBlur and onFocus event handlers.

onClick

(Event Handler)

Occurs when a clickable object is selected with the mouse.

<INPUT TYPE="elementType" onClick="function">
Usage

onClick offers a variety of functionality to buttons and other objects on a page. Buttons can be used to validate input before submitting or to compute the results of a form or equation. Clicking other objects, such as checkboxes and radio buttons, can trigger the capture of other information.

The following example sends the contents of the overtime form to the howRich function.

<FORM NAME="overtime">
Full days worked: <INPUT TYPE="text" VALUE="0" NAME="days" SIZE=3>
Hours worked: <INPUT TYPE="text" VALUE="0" NAME="hours" SIZE=30>
<INPUT TYPE="button" VALUE="Compute" NAME="computeWage" onClick="howRich(this.form)">
</FORM>
Related Items

Event handler of button, checkbox, radio, link, reset, and submit.

onFocus

(Event Handler)

Occurs when the user chooses a select, text, or textarea for input.

<INPUT TYPE="inputType" onFocus="function">
Usage

A form element receives focus when the user tabs to or clicks the input area with the mouse. Selecting within a field results in a select event.

One use of the onFocus function is for pop-up help when an item is selected for the first time.

Related Items

Event handler of select, text, and textarea.

See the onBlur and onChange event handlers.

onLoad

(Event Handler)

Occurs when a document finishes loading into a window or frameset.

<BODY onLoad="function">
<FRAMESET onLoad="function">
Usage

A load event is created when the browser finishes loading a window or all the frames within a <frameset> tag.

Related Items

Event handler of window.

See the onUnload event handler.

onMouseOver

(Event Handler)

Occurs when a mouse is placed over a hyperlink.

<A HREF="URL" onMouseOver="function">linkText</A>
Usage

onMouseOver occurs when the mouse pointer is placed over a link object. To function with the status or defaultStatus properties, the event handler must return true.

<A HREF="http://home.netscape.com/"
onMouseOver="window.status='Netscape Home'; return true">
Netscape</A>
Related Items

Event handler of link.

onSelect

(Event Handler)

onSelect occurs when text is highlighted within a form element.

<INPUT TYPE="textType" onSelect="function">
Usage

A select event is triggered by selecting some or all of the text in a text or textarea field.

Related Items

Event handler of text and textarea.

onSubmit

(Event Handler)

Occurs when a form is submitted by the user with the submit button.

<TAG onSubmit="function">
Usage

onSubmit is triggered when the user submits a form. Any return value other than false, including omitting the return statement, submits the form. To clarify the code, it is recommended to add return statements for both options.

<FORM onSubmit="feedbackSubmit()">
...form elements...
</FORM>

function feedbackSubmit () {
...statements...
if (!validData) {
return true }
else {
return false; }
}
Related Items

Event handler of form.

See the submit object.

See the submit method.

onUnload

(Event Handler)

Occurs when the user exits a document.

<BODY onUnload="function">
<FRAMESET onUnload="function">
Usage

When several unload events are included in a frame relationship, the order of operation proceeds from child to parent.

For example, an unload event is included with two documents and the parent <FRAMESET> tag that loaded them. When the child document changes, its unload event is triggered but the frameset unload is not affected. When the user selects an option that preempts the parent document for a new source, the top unload event is triggered.

Related Items

Event handler of window.

See the onLoad event handler.

open

(Method)

Creates a new document or window instance.

document.open([MIMEtype])
window.open("URL", "windowName" [,"windowFeatures"]
Usage

For a document, open opens a stream to collect the output of write or writeln methods. If the MIME type is a version of text or image such as text/html or image/gif, the document is opened for layout. Otherwise, the stream is routed to a plug-in. If a document already exists in the target window, then the open method clears it. The stream is ended by using the document.close() method.

For a window, open opens a new browser window in a similar fashion to choosing File, New Web Browser from the browser menu. Using the URL argument, it loads a document into the new window; otherwise, the new window is blank. When used as part of an event handler, the form must include the window object; otherwise, the document is assumed.

Window features are defined by a comma-separated list of options with =1 or =yes to enable and =0 or =no to disable. Window features include toolbar, location, directories, status, menubar, scrollbars, resizable, copyhistory, width, and height.

Related Items

Method of document and windowFONT>.

See the clear, close, write, and writeln methods.

options

(Property)

This array of options is a property of a select form element. The array is created by using <OPTION> tags within a set of <SELECT> tags.

formName.selectName.options[index]
forms[index].elements[index].options[index]
Usage

The first option's index is zero, the second is 1, and so on. For more detailed information, see the select object.

Related Items

See select object.

parent

(Property)

Refers to the calling document in the current frame created by a <frameset> tag.

parent
parent.frameName
parent.frames[index]
parent.property
Usage

Using parent allows access to other frames created by the same <FRAMESET> tag. For example, two frames invoked are called index and contents. The index frame can write to the contents frame using the syntax:

parent.contents.document.write("Kilroy was here.")
Related Items

Property of frame and window.

parse

(Method)

Takes a date string, such as Jan. 11, 1996, and returns the number of milliseconds since midnight, Jan. 1, 1970.

Usage

This function can be used to set date values based on string values. When passed a string with a time, it returns the time value.

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

Date.parse("Jan 11, 1996");
Today = new Date();
Date.parse(Today.toLocaleString())
Related Items

Method of Date.

See the UTC method.

parseFloat*

(Method)

parseFloat(string)
Usage

parseFloat parses a string argument and returns a floating-point number if the first character is a plus sign, minus sign, decimal point, exponent, or a numeral.

If parseFloat encounters a character other than one of the valid choices after that point, it returns the value up to that location and ignores all succeeding characters. If the first character is not a valid character, parseFloat returns one of two values based on the platform:

Windows0
Non-WindowsNaN
Related Items

See methods isNaN and parseInt.

parseInt*

(Method)

Parses a string argument and returns an integer based on a specified radix or base.

parseInt(string [,radix])
Usage

A radix of 10 converts the value to a decimal, whereas 8 converts to octal and 16 to hexadecimal. Values greater than 10 for bases above 10 are represented with letters A through F in place of numbers. Using a radix of 2 is used for binary number conversions.

Floating-point values are converted to integers. The rules for evaluating the string are identical to those for parseFloat.

If the radix is omitted or a radix which contradicts the initial characters, JavaScript assumes the radix based on the first characters of the string (see Table 21.3).

Table 21.3  Default Radix Based on the Initial String Characters

CharactersRadix
08 (octal)
0x16 (hexadecimal)
Any other10 (decimal)

Related Items

See the isNaN and parseFloat methods.

password

(Object)

A password element in an HTML form (see Figure 21.4).

document.formName.passwordName
document.forms[index].element[index]
Usage

A password is a text field that for security is masked with asterisks when entered by the user.

Any default values included as part of the HTML definition are cleared when the page is loaded. This prevents inadvertent or intentional security breaches. Even though the defaultValue property is valid for password, it always returns a null value.

The value of a password object can be evaluated programmatically within a script but it is recommended not to use a literal for obvious security reasons.

Figure 21.4: A password element is masked with asterisks for security.

Related Items

Property of form.

See the text object.

See the defaultValue, name, and value properties.

See the focus, blur, and select methods.

pathname

(Property)

Returns the path portion from an URL.

location.pathname
link.pathname
links[index].pathname
Usage

Although the pathname can be changed at any time, it is always safer to change the entire URL at once using the href property.

Related Items

Property of link and location.

See the hash, host, hostname, href, port, protocol, and search properties.

PI

(Property)

Returns the value of pi.

Math.PI
Usage

The value of Math.PI is approximately 3.14159. This is the ratio of the circumference of a circle to its diameter.

circumference = 2 * Math.PI * radius
area = Math.PI * Math.pow(radius,2)
Related Items

Property of Math.

See the E, LN2, LN10, LOG2E, LOG10E, SQRT1_2, and SQRT2 properties.

port

(Property)

Returns the port number of a URL address.

location.port
link.port
links[index].port
Usage

The port value is a substring of the host property in href.

Related Items

Property of link and location.

See the hash, host, hostname, href, pathname, protocol, and search properties.

pow

(Method)

Returns a base raised to an exponent.

Math.pow(argument)
Usage

Many languages use the caret operator (^) to calculate an exponent. JavaScript includes its own method to do this. The caret is used in JavaScript to calculate a bitwise XOR operation.

Related Items

Method of Math.

See the exp and log methods.

prompt

(Method)

Displays a prompt dialog box that accepts user input (see Figure 21.5).

[windowName.]prompt(message [inputDefault])
Usage

If an initial value is not specified for inputDefault, the dialog box displays the <undefined> value. Generating the prompt in Figure 21.5 required one line of code:

var userid = prompt("Please enter your ID","")

Figure 21.5: The prompt dialog box is used to get user input outside of a form.

Related Items

Method of window.

See the alert and confirm methods.

protocol

(Property)

Returns the file access method.

location.protocol
link.protocol
links[index].protocol
Usage

The string returned by this property is the initial portion of a URL, up to and including the colon. This is the part of the URL that indicates the access method (http, ftp, mailto, etc.).

aboutInformation about the client browser.
ftp AFile transfer protocol address for downloading files.
httpHypertext transfer address that is the basis of the World Wide Web.
mailtoAn e-mail address.
newsA usenet news site.
fileRefers to a file on the local machine.
javascriptPrecedes a set of JavaScript commands.

Related Items

Property of link and location.

See the hash, host, hostname, href, pathname, port, and search properties.

radio

(Object)

A set of radio buttons.

formName.radioName[index]
forms[index].elements[index]
Usage

radio objects are created within HTML <form> tags and represent radio buttons. A set of radio buttons enables the user to select one item from a group of options.

When referencing the object using the radio button name, the index is comprised of the buttons with the same name property. When referring to a radio button using the
elements array, each button is a separate item in the index.

Related Items

Property of form.

See the checkbox and select objects.

See the checked, defaultChecked, index, length, name, and value properties.

See the click method.

See the onClick event handler.

random

(Method)

Returns a random number between 0 and 1 (UNIX only).

Math.random()
Usage

The random method is only enabled on UNIX platforms-Windows and Macintosh users need to use an alternative form of generating a random number. An example of this type of usage is included in the Task Reference at the end of this book.

Related Items

Method of Math.

referrer

(Property)

URL of the document which led to the current document.

document.referrer
Usage

Returns a read-only string containing the complete URL of the document that called the current document. It can be used with a CGI script to keep track of how users are linked to a page.

document.write("Click <A HREF=\''"+document.referrer+"\'>here</A> to go back from whence you came.">
Related Items

Property of document.

reset

(Object)

Button to return a form to its default values.

formName.resetButtonName
forms[index].elements[index]
Usage

This button correlates with an HTML reset button, which resets all form objects to their default values.

A reset object must be created within a <form> tag and cannot be controlled through the onClick event handler. When the button is clicked, the form is reset. However, the event handler can invoke other actions with the reset.

Related Items

Property of form.

See the button and submit objects.

See the name and value properties.

See the click method.

See the onClick event handler.

round

(Method)

Rounds a number to the nearest integer.

Math.round(argument)
Usage

Returns the value of a floating-point argument rounded to the next highest integer if the decimal portion is greater than or equal to .5, or the next lowest integer if less than .5.

Math.round(2.1) //Returns 2
Math.round(2.9) //Returns 3
Related Items

Method of Math.

search

(Property)

Returns any query information attached to a URL.

location.search
linkName.search
links[index].search
Usage

Returns a string containing any query information appended to a URL. Query data is preceded by a question mark and is the last item included in the document URL. Information in the string is formatted this way:

?elementName=element+value

Like all substrings of the href property, search can be changed at any time.

Related Items

Property of link and location.

See the hash, host, hostname, href, pathname, port, and protocol properties.

select (options array)

(Object)

A selection list or scrolling list on an HTML form (see Figure 21.6).

formName.selectName
forms[index].elements[index]
formName.selectName[index].options[index]
forms[index].elements[index].options[index]
Usage

A selection list enables the user to choose one item from a list. A scrolling list enables the choice of one or more items from a list, enabled using the MULTIPLE attribute in the input tag.

When used without the options array, the select object refers to the entire list, using options such as length and name. The value and selectedIndex indicate the currently selected option in a selection list or the first selected item of a scrolling list.

Related Items

Property of form.

See the radio object.

See the length, name, options, and selectedIndex properties.

See the blur and focus methods.

See the onBlur, onChange, and onFocus event handlers.

For the options property of select, see the defaultSelected, index, selected, text, and value properties.

Figure 21.6: A drop-down selection list from an HTML form allows one choice, whereas a scrolling list allows multiple choices.

select

(Method)

Selects the input area of a specified form element.

formName.elementName.select()
forms[index].elements[index].select()
Usage

Used with the focus method, JavaScript can highlight a field and position the cursor for user input.

Related Items

Method of password, text, and textarea.

See the blur and focus methods.

selected

(Property)

Returns a Boolean value (true or false) indicating the current state of an option in a select object.

formName.elementName.[options[index].]selected
forms[index].elements[index].[options[index].]selected
Usage

The selected property can be changed at any time and the display will immediately update to reflect the new value. The selected property is useful for select elements that are created using the multiple attribute.

Using the select property, you can view or change the value of any element in an
options array without changing the value of any other element in the array.

Related Items

Property of options.

See the defaultSelected, index, and selectedIndex properties.

selectedIndex

(Property)

Returns an integer specifying the index of a selected item.

formName.elementName.[options[index].]selected
forms[index].elements[index].[options[index].]selected
Usage

The selectedIndex property is useful for select elements that are created without using the MULTIPLE attribute in the <SELECT> tag. If selectedIndex is evaluated when the MULTIPLE attribute is set, the property returns the index of the first option only. Setting the property clears any other options that are selected in the element.

Related Items

Property of select, options.

See the defaultSelected, index, and selected properties.

self

(Property)

Refers to the current window or form.

self
Usage

The self property is useful for removing ambiguity when dealing with window and form properties of the same name.

Related Items

Property of frame and window.

See the window property.

setDate

(Method)

Sets the day of the month.

Date.setDate(argument)
dateName.setDate(argument)
Usage

setDate uses an integer from 1 to 31 to set the day of the month for a Date object.

endOfTheWorld = new Date("January 11, 1996 06:18:00")
endOfTheWorld.setDate(26)
document.write(endOfTheWorld.getDate()) //Returns 26
Related Items

Method of Date.

See the getDate method.

setHours

(Method)

Sets the hour for the current time.

Date.setHours(argument)
dateName.setHours(argument)
Usage

setHours uses an integer from 0 (midnight) to 23 (11 p.m.) to set the hour of the day using military time.

Related Items

Method of Date.

See the getHours method.

setMinutes

(Method)

Sets the minutes for the current time.

Date.setMinutes(argument)
dateName.setMinutes(argument)
Usage

Uses an integer from 0 to 59 to set the minutes of a date object.

Related Items

Method of Date.

See the getMinutes method.

setMonth

(Method)

Sets the month value of a date object.

Date.setMonth(argument)
dateName.setMonth(argument)
Usage

Uses an integer from 0 (January) to 11 (December). This is the one item of the Date object that doesn't follow normal numbering conventions. Be sure to make the adjustment when transferring values from the JavaScript month to a form understandable by the user.

Related Items

Method of Date.

See the getMonth method.

setSeconds

(Method)

Sets the seconds.

Date.setSeconds(argument)
dateName.setSeconds(argument)
Usage

Uses an integer from 0 to 59 to set the seconds of a date object. Although the Date object uses milliseconds to track time, seconds are the greatest level of detail allowed when entering a specific time.

Related Items

Method of Date.

See the getSeconds method.

setTime

(Method)

Sets the value of a date object.

dateName.setTime(argument)
Usage

This is the base form of a Date object. It returns the number of milliseconds since midnight on Jan. 1, 1970. Although it is not necessary to know this number, it can be used as a simple method of copying the value of one date object to another.

endOfTheWorld = new Date(userGuess)
checkDate = new Date()
checkDate.setTime(endOfTheWorld.getTime())
Related Items

Method of Date.

See the getTime method.

setTimeout

(Method)

Evaluates an expression after a specified amount of time, expressed in milliseconds.

[window.]setTimeout(timerID)
[windowName.]setTimeout(timerID)
Usage

Timeouts are not repeated indefinitely. For example, setting a timeout to 3 seconds evaluates the expression once after 3 seconds-not every 3 seconds.

To call setTimeout recursively, reset the timeout as part of the function invoked by the method. Calling the function startclock in the following example sets a loop in motion that clears the timeout, displays the current time, and sets the timeout to redisplay the time in 1 second.

<SCRIPT>
var timerID = null;
var timerRunning = false;

function stopclock () {
  if(timerRunning) clearTimeout(timerID);
  timerRunning=false;
}
function startclock () {
  stopclock();
  showtime();
}
function showtime () {
  var now = new Date();
  document.clock.display.value = now.toLocaleString();
  timerID = setTimeout("startclock()",1000);
  timerRunning = true;
}
</SCRIPT>

<BODY onLoad="startclock()">
<FORM NAME="clock">
<INPUT ITEM=text NAME="display" VALUE="Standby for the time">
</FORM>
</BODY>
Related Items

Method of window.

See the clearTimeout method.

setYear

(Method)

Sets the year in the current date.

Date.setYear(argument)
dateName.setYear(argument)
Usage

setYear needs a 2-digit integer representing the year minus 1900.

Related Items

Method of Date.

See the getYear method.

sin

(Method)

Returns the sine of an argument.

Math.sin(argument)
Usage

The argument is the size of an angle expressed in radians and the returned value is from -1 to 1.

Related Items

Method of Math.

See the acos, asin, atan, cos, and tan methods.

small

(Method)

stringName.small()
Usage

small formats a string object into a small font using the HTML <small> tags.

Related Items

Method of string.

See the big and fontsize methods.

sqrt

(Method)

Returns the square root of a positive numeric expression.

Math.sqrt(argument)
Usage

If the argument's value is outside the range, the returned value is 0.

SQRT1_2

(Property)

The square root of 1/2.

Math.SQRT1_2
Usage

The square root of 1/2 is also expressed as the inverse of the square root of 2 (approximately 0.707).

Related Items

Property of Math.

See the E, LN2, LN10, LOG2E, LOG10E, PI, and SQRT2 properties.

SQRT2

(Property)

The square root of 2.

Math.SQRT2
Usage

The value of this constant is approximately 1.414.

Related Items

Property of Math.

See the E, LN2, LN10, LOG2E, LOG10E, PI, and SQRT1_2 properties.

status

(Property)

Specifies a priority or transient message to display in the status bar.

window.status
[windowName].status
Usage

The status bar is located at the bottom of the window. A user status message is usually triggered by a mouseOver event from an anchor. To display a message in the status bar when the mouse pointer is placed over a link, the usage is:

<A anchorDefinition onMouseOver="window.status='Your message.'; return true">link</A>

Note the use of nested quotes and use of return true, needed for operation.

Once invoked, the message remains until the mouse is placed over another link.

Related Items

Property of window.

See the defaultStatus property.

string

(Object)

A series of characters defined by double or single quotation marks.

stringName
Usage

For example:

myDog = "Brittany Spaniel"

returns a string object called myDog with the Brittany Spaniel value. Quotation marks are not a part of the string's value-they are only used to delimit the string.

The object's value is manipulated using methods that return a variation on the string-for example myDog.toUpperCase() returns BRITTANY SPANIEL. A string object also includes methods that return HTML versions of the string, such as bold and italics.

Related Items

See the text and textarea objects.

See the length property.

See the anchor, big, blink, bold, charAt, fixed, fontcolor, fontsize, indexOf, italics, lastIndexOf, link, small, strike, sub, substring, sup, toLowerCase, and toUpperCase methods.

strike

(Method)

Formats a string object as strikeout text.

stringName.strike()
Usage

Using strike is identical to using HTML <strike> tags.

Related Items

Method of string.

See the blink, bold, and italics methods.

sub

(Method)

Formats a string object into subscript text.

stringName.sub()
Usage

Using sub is identical to using HTML <sub> tags.

Related Items

Method of string.

See the sup method.

submit

(Object)

A submit button on an HTML page.

formName.buttonName
forms[index].elements[index]
Usage

Clicking the button causes the form to be submitted to the program specified by the action property. The button is created within an HTML <form> tag, and always loads a new page, which may be the same as the current page if an action isn't specified.

Related Items

Property of form.

See the button and reset objects.

See the name and value properties.

See the click method.

See the onClick event handler.

submit

(Method)

Performs the same action as clicking a submit button.

formName.submit()
forms[index].submit()
Usage

The information from the form is submitted depending on the attribute of the METHOD attribute-get or post.

Related Items

Method of form.

See the submit object.

See the onSubmit event handler.

substring

(Method)

Returns a subset of a string object based on two indexes.

stringName.substring(index1, index2)
Usage

If the indexes are equal, an empty string is returned. Regardless of order, the substring is built from the smallest index to the largest.

Related Items

Method of string.

sup

(Method)

Formats a string object into superscript text.

stringName.sup()
Usage

Using sup is identical to using HTML <sup> tags.

Related Items

Method of string.

See the sub method.

tan

(Method)

Returns the tangent of an argument.

Math.tan(argument)
Usage

The argument is the size of an angle expressed in radians.

Related Items

Method of Math.

See the acos, asin, atan, cos, sin methods.

target

(Property)

A string specifying the name of a window for posting responses to after a form is submitted.

formName.target
forms[index].target
location.target
link.target
links[index].target
Usage

Normally used to view the destination for a form submission, target can also be used to view or change a link's destination. For a link, target returns a string specifying the name of the window that displays the content of a selected hypertext link.

homePage.target = "http://www.wossamotta.edu/"

You must use a literal to set the target property. JavaScript expressions and variables are invalid entries.

Related Items

Property of form, link, and location.

See the action, encoding, and method properties.

text

(Object)

A one-line input field on an HTML form (see Figure 21.7).

formName.textName
forms[index].elements[index]

Figure 21.7: Text input boxes are objects within the form.

Usage

text objects accept characters or numbers. A text object can be updated by assigning new contents to its value.

Related Items

Property of form.

See the password, string, and textarea objects.

See the defaultValue, name, and value properties.

See the focus, blur, and select methods.

See the onBlur, onChange, onFocus, and onSelect event handlers.

text

(Property)

Returns the value of text following the <option> tag in a select object.

formName.selectName.options[index].text
forms[index].elements[index].options[index].text
Usage

text can also be used to change the value of the option, with an important limitation: although the value is changed, its appearance on-screen is not.

Related Items

Property of options.

textarea

(Object)

textarea is similar to a text object, with the addition of multiple lines (see Figure 21.8).

formName.textAreaName
forms[index].elements[index]
Usage

A textarea object can also be updated by assigning new contents to its value. The screen is updated immediately after the new value is assigned.

<FORM>
<ITEM INPUT=textarea NAME="sponsorMessage" VALUE="And now a brief message from our sponsor.">
</FORM>
...
<SCRIPT>
sponsorMessage.value = "Now is the time \r\nfor everybody to get up \r\nand run away."
</SCRIPT>

Note the use of the newline character \n. The implementation of a new line depends on the platform. For Windows, it's the combination \r\n; for Macintosh and UNIX, it's \n.

When defining a textarea in a form, you can load a default value by including text between the <TEXTAREA> tags. The following example loads three lines of text and a blank line into a textarea element.

<BR><TEXTAREA NAME="user_comments" ROWS=4 COLS=40>
Enter your comments here.

Or just press the submit button to let us
know you liked what you saw.
</TEXTAREA>

Figure 21.8: The textarea object can accept multiple lines of text from the user.

Related Items

Property of form.

See the password, string, and text objects.

See the defaultValue, name, and value properties.

See the focus, blur, and select methods.

See the onBlur, onChange, onFocus, and onSelect event handlers.

title

(Property)

Returns the read-only value set within HTML <title> tags.

document.title
Usage

If a document doesn't include a title, the value is null.

Related Items

Property of document.

toGMTString

(Method)

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

Date.toGMTString()
dateName.toGMTString()
Usage

This string conversion returns a string containing the time in a GMT format, which can vary depending on the platform.

For example, if today is a date object:

today.toGMTString()

then the string "Thu, 11 Jan 1996 06:05:15" is returned. Actual formatting may vary from platform to platform. The time and date are based on the client machine.

Related Items

Method of Date.

See toLocaleString method.

toLocaleString

(Method)

Converts a date object to a string using the local conventions.

Date.toLocaleString()
dateName.toLocaleString()
Usage

The date string returned by this method depends on the preferences defined on the client machine, such as mm/dd/yy hh:mm:ss.

Related Items

Method of Date.

See the toGMTString method.

toLowerCase

(Method)

Converts all characters in a string to lowercase.

stringName.toLowerCase()
Usage

The results of the toLowerCase method are displayed entirely in lowercase characters although the actual contents of the string are not changed.

Related Items

Method of string.

See the toUpperCase method.

top

(Property)

The top-most browser window.

top
top.frameName
top.frames[index]
Usage

Also called an ancestor or Web browser window, the top property refers to the highest precedence window that contains frames or nested framesets.

Related Items

Property of window.

toUpperCase

(Method)

Converts all characters in a string to uppercase.

stringName.toUpperCase()
Usage

Although it affects the immediate display of the string, toUpperCase does not affect the value of its object.

Related Items

Method of string.

See the toLowerCase method.

unescape*

(Method)

Returns a character based on its ASCII value.

unescape(string)
Usage

The value returned is expressed as a string in the format %xxx where xxx is a decimal number between zero and 255, or 0x0 to 0xFF in hex.

Related Items

See the escape method.

userAgent

(Property)

Header sent as part of HTTP protocol from client to server to identify the type of client.

navigator.userAgent
Usage

The syntax of the returned value is the same as for appVersion, with the addition of the browser application code name.

codename/releaseNumber (platform; country)
Related Items

Property of navigator.

See the appName, appVersion, and appCodeName properties.

UTC

(Method)

Returns the number of milliseconds for a universal coordinated time (UTC) date since midnight, January 1, 1970.

Date.UTC(year, month, day [, hrs] [, min] [, sec])
Usage

UTC is always calculated from the same date, and therefore, always used as Date.UTC(), not with a created date object. When including the value for the month, don't forget that JavaScript numbers the months from 0 to 11.

Related Items

Method of Date.

See the parse method.

value

(Property)

Returns the value of an object.

formName.buttonName.value
formName.resetName.value
formName.submit.value
formName.checkboxName.value
formName.radioName.value
formName.hiddenName.value
formName.textName.value
formName.textareaName.value
formName.selectName.value
formName.passwordName.value
forms[index].elements[index].value
Usage

The value of an object depends on the type of object it is applied to (see Table 21.4).

Table 21.4  Values of Various Form Objects

ObjectValue Attribute
button, reset, submit Value attribute that appears on-screen, not the button name
checkbox On if item is selected, off if not
radio String reflection of value
hidden, text, textarea Contents of the field
select Reflection of option value
password Returns a valid default value, but an encrypted version if modified by the user

Changing the value of a text or textarea object results in an immediate update to the screen. All other form objects are not graphically updated when changed.

Related Items

Property of button, checkbox, hidden, options, password, radio, reset, submit, text, and textarea.

For password, text, and textarea, see the defaultValue property.

For button, reset, and submit, see the name property.

For options, see the defaultSelected, selected, selectedIndex, and text properties.

For checkbox and radio, see the checked and defaultChecked properties.

vlinkColor

(Property)

Returns or sets the color of visited links.

document.vlinkColor
Usage

Like all colors, vlinkColor uses hexadecimal RGB triplets or a string literal. The property cannot be set after the document has been formatted. To override the browser defaults, color settings are used with the onLoad event handler in the <BODY> tag:

<BODY onLoad="document.vlinkColor='aliceblue'">
Related Items

Property of document.

See the alinkColor, bgColor, fgColor, and linkColor properties.

window

(Object)

The highest precedence object accessible by JavaScript relating to an open Navigator window.

window
self
top
parent
windowName
propertyName
methodName(parameters)
Usage

window is created by Navigator when a page is loaded containing properties that apply to the whole window. It is the top-level object for each document, location, and history object. Because its existence is assumed, you do not have to reference the name of the window when referring to its objects, properties, or methods.

For example, the following two lines have the same result (printing a message to the status line):

status="Go away from here."
window.status="Go away from here."

There are numerous ways of referencing a window, depending on its relation to the current location as outlined in Table 21.5.

Table 21.5  Window Aliases

Window NameReference
window, self The window containing the current document. When these aliases are omitted, the current document is still assumed. The exception is in scripting event handlers, where methods such as open and close must be used with specific windows or frames.
Top Refers to the top most window. Useful for parent-child-child relationships created with multiple <FRAMESET> tags.
Parent The window containing the <FRAMESET> tag that created the current window.
WindowName Used to reference the window in HTML tags. When using properties and methods of a window, use the name of the window variable.

A new window is created using the open method:

aNewWindow = window.open("URL","Window_Name"[,"windowFeatures"])

The variable name is used to refer to the window's properties and methods. The window name is used in the target argument of a form or anchor tag. The list of features (shown in Table 21.6) controls the appearance and functionality of the browser (see Figure 21.9).

Table 21.6  Window Feature Attributes

OptionUse
toolbar Includes standard toolbar, including forward, back, home, and print buttons.
location Creates a location object.
directories In Netscape, includes the list of buttons for standard links, such as What's New, What's Cool, and Handbook.
status Creates a status bar at the bottom of the screen.
menubar Includes the menubar at the top of the screen, including items such as File, Edit, and View.
scrollbars Adds scrollbars if the document extends beyond the size of the screen.
resizable Allows the user to modify the size of the window.
width Initial window width, in pixels.
height Initial window height, in pixels.

Figure 21.9: Some of the various features of a Navigator window are controlled through the window.open method.

If no features are listed, all are included by default. If any feature is explicitly defined, any not included in the feature list are excluded by default.

Related Items

See the document and frame objects.

See the defaultStatus, frames, parent, self, status, top, and window properties.

See the alert, close, confirm, open, prompt, setTimeout, and clearTimeout methods.

See the onLoad and onUnload event handlers.

window

(Property)

A synonym for the current window.

frameName.window
[windowName.]window
Usage

The window property is used to remove ambiguity between a window and form object of the same name. Although window also