Appendix E

Built-in Objects and Functions


CONTENTS

This appendix describes JavaScript's built-in objects and functions. The browser creates some of the objects in response to HTML elements in your Web page, and others are simply part of the language and available all the time.

Built-in objects

JavaScript defines several intrinsic objects. Like the objects that you can define, they have methods and properties. They may also have event handlers, which are JavaScript expressions that JavaScript executes when a specific kind of event occurs.

The anchors Array

The anchors array is an array of anchor objects. It is a property of the document object. Anchor objects are reflections of A elements that have a NAME attribute:

<A NAME="anchorName">anchorText</A>

You can add anchors to the anchors array, but you cannot remove, replace, or modify them.

The anchors array has one property:

lengthThe number of entries in the anchors array. You cannot change this property directly, but you can create new anchors with the string anchor() method; such newly created anchors are added to the anchors array.

The button Object

A button object is a reflection of an INPUT element with a TYPE attribute of "button":

<INPUT TYPE="button">

button objects are members of the containing form object's elements array.

A button object has two properties:

nameThe INPUT element's NAME attribute.
valueThe INPUT element's VALUE attribute. This is the button's label in the display. In the absence of a VALUE attribute, this property is an empty string. You cannot change this property.

A button object has one method:

click()Simulates a mouse click on the button. The onClick event handler is not executed when click() is called.

The button object has one event handler:

onClickExecuted when the user clicks on the button.

The checkbox Object

A checkbox object is a reflection of an INPUT element with a TYPE attribute of "checkbox":

<INPUT TYPE="checkbox">

checkbox objects are members of the containing form's elements array.

A checkbox object has four properties:

checkedA Boolean value that indicates whether the checkbox object is on or off. The checkbox object is on if checked is true. You can change checked at any time. Changing checked changes the appearance of the display immediately.
Default-CheckedA Boolean value that indicates the default state of the checkbox object. The default state of the checkbox object is on if defaultChecked is true. The initial value of defaultChecked is set from the INPUT tag's CHECKED attribute. You can change defaultChecked at any time. Changing defaultChecked has no effect on the appearance of the display.
nameThe value of the INPUT tag's NAME attribute. You can change it at any time.
valueThe value of the INPUT tag's VALUE attribute. value is "on" in the absence of a VALUE attribute. The browser returns this property to the server if the user selected the checkbox. value is not part of the displayed object. You can change this property at any time.

A checkbox object has one method:

click()Sets the checked property. The onClick event handler is not executed.

A checkbox has one event handler:

onClick

Executed when the user clicks on the display object.

The Date Object

Date objects provide a mechanism for dealing with dates and time. At this time, JavaScript does not support dates before January 1, 1970 or after December 31, 1999.

There are three ways to create a Date object:

Date();Uses the current local date and time.
Date(string);Uses a string of "month day, year hours:minutes:seconds"; you can omit the time portion.
Date(year, month, day, hours, minutes, seconds); The parameters are integers; you can omit the time portion.

Date objects have 20 methods:

getDate()Returns the day of the month from the date object. The value returned is between 1 and 31.
getDay()Returns the day of the week from the date object. The value returned is between 0 (Sunday) and 6 (Saturday).
getHours()Returns the hour from the date object. The value returned is between 0 and 23.
getMinutes()Returns the minutes from the date object. The value returned is between 0 and 59.
getMonth()Returns the month from the date object. The value returned is between 0 (January) and 11 (December).
getSeconds()Returns the seconds from a date object. The value returned is between 0 and 59.
getTime()Returns the number of milliseconds from January 1, 1970, 00:00:00.000 to the time in the date object.
GetTimeZoneOffset()Returns the difference, in minutes, between local time and Greenwich Mean Time (GMT).
getYear()Returns the year from a date object. The value returned is the year minus 1900.
Date.parse (dateString)Returns the number of milliseconds between date-String and January 1, 1970, 00:00:00.000 local time. The string may be of the form DDL dd MMM YYYY HH:MM:SS TZ. DDD is the first three letters of the day of the week. dd is the day of the month from 1 to 31. MMM is the first three letters of the month. YYYY is the year. HH is the hour. MM is the minute. SS is the second. TZ is the time zone. parse() recognizes GMT, UTC, and the continental United States time zone abbreviations. You can express the time zone as GMT+HHMM, indicating an offset of HH hours and MM minutes from GMT. If you omit the time zone, the browser assumes local time.
SetDate (number)Sets the day of the month in a date object to number. If number is inappropriate to the date, JavaScript automatically adjusts the month and date. For example, if the month in a Date object is April and you call setDate()to set the date to 31, the date will be May 1 instead of April 31.
SetHours (number)Sets the hours in a date object to number.
SetMinutes (number)Sets the minutes in a date object to number.
SetMonth (number)Sets the month in a date object to number. If the resulting combination of month and date is inappropriate, JavaScript automatically adjusts the month and date. For example, if the date is May 31, and you use setMonth() to set the month to April, the date becomes May 1, not April 31st.
setSeconds (number)Sets the seconds in a date object to number.
setTime (number)Sets the date and time in a date object to the value indicated by number. number is the number of milliseconds since 1 January 1970 00:00:00.000
setYear (number)Sets the least significant two digits of year in the date object to number. If the result is a date prior to 1970, the date will be January 1 1970 00:00:00.
ToGMTString()Converts a date object to a string representation using the local platform's GMT conventions.
ToLocale-String()Converts a date object to a string representation using the local platform's locale conventions. You should not use the resulting string to pass a date, as the representation is highly platform-dependent.
Date.UTC (year, month, day, hour, minute, second) Converts the specified date into the number of milliseconds between the specified date and January 1, 1970, 00:00:00.000. The hour, minute, and second parameters are optional and default to 0.

The document Object

The document object contains information about the currently displayed document. Its properties are derived from the document's BODY element:

<BODY>document contents</BODY>

The document object has 13 properties:

alinkColorA string representing the color of an active link. It has the value of BODY tag's ALINK attribute. You cannot change this property after the document has been displayed.
anchorsAn array, in source order, of named A tags.
bgColorA string representing the color of the background. It initially has the value of the BODY tag's BGCOLOR attribute. You can change this property at any time.
cookieThe string representation of an element of the cookie.txt file. You can change this property at any time.
fgColorA string representing the color of the text. It has the value of the BODY tag's TEXT attribute. You cannot change this property after the document has been displayed.
formsAn array of references to the form objects in the document. The form objects are in source order.
LastModifiedA string representing the document's last modification date. JavaScript formats the date for local time. Not all servers make this information available to the browser; in such cases, this property will represent a date of 1 January 1970 00:00:00 GMT, converted to local time. You cannot modify this property.
linkColorA string representing the color of unvisited links. It has the value of the BODY tag's LINK attribute. You cannot change this property after the document has been displayed.
linksAn array of references to the link objects in the document. The link objects are in source order.
locationA string that represents the document's URL. It is not the same as the window's location object. You cannot change location.
referrerA string that represents the URL of the calling document of this document. You cannot change this property.
titleA string that represents the contents of the document's TITLE tag. If a document has no TITLE tag or if the browser does not display its TITLE element contents (that is, the document is in a frame), this property is null. You cannot change this property.
vlinkColorA string representing the color of a visited link. It has the value of the BODY tag's VLINK attribute. You cannot change this property after the document has been displayed.

The document object has five properties:

clear()Clears the document in a window.
close()Closes an output stream opened by open(). close() forces the stream contents to display if the stream was open for layout.
open() open (mimeType)Opens a stream to collect the output of the write() and writeln() methods. open() clears the target window. If mimeType is a text or image type, the stream is open for layout. mimeType is one of the following:

"text/html"-a document consisting of HTML-formatted ASCII text.

"text/plain"-a document consisting of ASCII text with end-of-line characters to delimit displayed lines.

"image/gif"-a document consisting of a GIF header and pixel data.

"image/jpeg"-a document consisting of a JPEG header and pixel data.

"image/x-bitmap"-a document consisting of a bitmap header and pixel data.

plugIn-the name of a plug-in.

If you do not specify mimeType, the default is "text/html".

Write (expression)Displays expression to a document window.
Writeln (expression)Displays expression and a new line to a document window.

The elements Array

The elements array contains references to input elements in a form. You cannot add elements to this array, replace elements in the array, or remove elements from the array. The elements array is a form object property. The elements array has one property:

lengthThe number of entries in the elements array. You cannot change this property.

The form Object

A form object collects input from the user and may send the input to a server. It is a reflection of a FORM element:

<FORM>form contents</FORM>

Each form object is a member of the containing document object's forms array.

A form object has six properties:

actionThe FORM tag's ACTION attribute. You can change this property at any time.
ElementsAn array of the form object's input elements in source order. Each radio button is a separate form element and a separate entry in the array.
EncodingThe FORM tag's ENCTYPE attribute. You can change this property at any time.
LengthThe number of elements in the form object. You cannot change this property.
MethodThe FORM tag's METHOD attribute. You can change it at any time.
TargetThe FORM tag's TARGET attribute. This is the name of the window that displays the response after the user submits formName. You can change it at any time.

The form object has one method:

submit()Submits the form's data to the server.

The form object has one event handler:

onSubmitExecuted when the user clicks on the form's SUBMIT button. If the event handler returns false, JavaScript does not send the form's data to the server. If the event handler returns true or fails to execute a return statement, JavaScript sends the form's data to the server.

The forms Array

The forms array is a property of the containing document object. It contains references to all of the form objects in the document, in source order. You cannot add a form to the array, replace a form in the array, or remove a form from the array.

The forms array has one property:

length

The number of entries in the forms array. You cannot change this property.

The frame Object

A frame object is a reflection of a FRAME element:

<FRAME>

A frame object has six properties:

framesAn array of nonempty frame objects in this frame object in source order.
lengthThe number of frames in this frame object. A frame that does not load a document containing a FRAMESET tag has a length of 0. You cannot change this property.
nameThe FRAME tag's NAME attribute. You can change it at any time.
parentA synonym for the window or frame object that contains this frame object. You cannot change this property.
selfA synonym for this frame object. You cannot change this property.
windowA synonym for this frame object. You cannot change this property.

A frame object has two methods:

clearTimeout (timeoutID)Cancels timeoutID, which is a timer reference returned by a previous call to setTimeout().
SetTimeout (expression, time)Evaluates expression after time milliseconds. Returns a timer reference that can be used in a call to clearTimeout().

The frames Array

A frames array contains the nonempty frames within a frame or a window. It has one property:

lengthThe number of nonempty frame objects in this frame array. You cannot change this property.

The hidden Object

A hidden object is a reflection of an INPUT element with a TYPE attribute of "hidden":

<INPUT TYPE="hidden">

hidden objects are members of the containing form object's elements array.

A hidden object has three properties:

defaultValueThe default value for hiddenName. Initially, it is the value of the INPUT tag's VALUE attribute. You can change this property at any time.
nameThe INPUT tag's NAME attribute. You can change it at any time.
valueThe INPUT tag's VALUE attribute. You can change it at any time.

The history Object

The history object contains information on URLs that the user has visited in a window and provides methods to revisit those URLs. The URLs themselves are not visible to you, and you cannot add URLs to a history object or take URLs away from a history object. The history object has one property:

lengthThe number of entries in the history object. You cannot modify the length property.

The history object has three methods:

back()Loads the previous URL in the history list. Performs the same action as selecting the Back button in the navigator.
Forward()Loads the next URL in the history list. Performs the same action as selecting the Forward button in the navigator.
go(arg)Loads the specified URL in the history list. If arg is an integer, it is an index into the history list, with positive values indexing forward into the list and negative values indexing backward into the list. history.go(-1) is equivalent to history.back() and history.go(1) is equivalent to history.forward(). history.go(0) forces the browser to reload the current URL. If arg is a string, the browser loads the nearest URL in the history list that has arg as a substring. The comparison is case-insensitive.

The link Object

A link object is a reflection of an A element that has an HREF attribute:

<A HREF=url>anchorText</A>

All links are members of the document's links array in source order.

URLs specify the location of documents on the Internet, and the protocol that is used to retrieve them. The general format of a URL is

protocol hostname port pathname search hash

These are defined as follows:

protocolThe beginning of a URL, up to the first colon. Common protocols include javascript: (JavaScript code), about: (navigator information), http: (World Wide Web), file: (local file), ftp: (ftp), mailto: (mail), news: (Usenet news), and gopher: (gopher). The protocol may be separated from the rest of the URL by two slashes (http:, ftp:, news:), three slashes (file:), or no slashes (javascript:, about:, mailto:, gopher:).
HostnameThe host and domain name, or IP address, of a network host.
PortThe number of the communications port used by the network host for communication. Many protocols define a "well-known" port number (21 for ftp, 70 for gopher, 80 for the World Wide Web, 119 for Usenet news, to name a few) for the protocol, and because most hosts use the well-known port numbers, the port component is rarely used.
PathnameThe path of the file, including the file name, on the network host.
SearchQuery information, beginning with a question mark.
HashAn anchor name, beginning with a hash mark (#)

A link object has nine properties:

hashThe hash component of the A element's HREF attribute.
hostThe hostname and port components of the A element's HREF attribute. The strings are separated by a colon. If there is no port component, this property is the hostname component of the A element's HREF attribute.
hostnameThe hostname portion of the A element's HREF attribute.
hrefThe entire HREF attribute of the A element. You can change this property at any time.
pathnameThe pathname component of the A element's HREF attribute.
portThe port component of the A element's HREF attribute.
protocolThe protocol component of the A element's HREF attribute.
searchThe search component of the A element's HREF attribute.
targetThe A element's TARGET attribute. This is the name of the window or frame that displays the document when the browser loads the document. You can change it at any time.

The link object has two event handlers:

onClickExecuted when the user clicks on the display object.
OnMouseOverExecuted when the mouse pointer moves over the display object from outside the object. The onMouseOver event handler must return true if it wants to set the window's status or defaultStatus properties.

The links Array

The links array contains references to all of the links in the document, in source order. You cannot remove a link from the array or replace a link in the array. You can create another link with the string object's link() method.

The links array has one property:

lengthThe number of entries in the links array. You cannot change this property.

The location Object

The location object contains information about a window object's Uniform Resource Locator (URL). It has no methods or event handlers, and its properties consist of the URL and its components. You can change a window object's location, effectively forcing the window to be reloaded from a new URL. Although you can reload a window by changing part of its URL, you should change the entire URL by loading a new URL string into the href property instead.

The location object has eight properties:

hashThe hash component of the window's URL.
hostThe hostname component of the window's URL, plus the port component. The hostname and port components are separated by a colon. If there is no port component, this is simply the hostname component.
hostnameThe hostname component of the window's URL.
hrefThe window's entire URL.
pathnameThe pathname component of the window's URL.
portThe port component of the window's URL.
protocolThe protocol component of the window's URL.
searchThe search component of the window's URL.

The Math Object

The Math object provides common mathematical functions, and its properties provide useful mathematics constants. You cannot create a Math object. You cannot modify any of the eight properties:

Math.EEuler's constant (approximately 2.718281828459).
Math.LN2The natural logarithm of 2 (approximately 0.6931471805599).
Math.LN10The natural logarithm of 10 (approximately 2.302585092994).
Math.LOG2EThe base 2 logarithm of Euler's constant, e (approximately 1.442695040889).
Math.LOG10EThe base 10 logarithm of Euler's constant, e (approximately 0.4342944819033).
Math.PIThe ratio of a circle's circumference to its diameter (approximately 3.14159265359).
Math.SQRT1_2The square root of one half (approximately 0.7071067811865).
Math.SQRT2The square root of 2 (approximately 1.414213562373).

The Math object provides 17 methods:

Math.abs(number)Returns the absolute value of number.
Math.acos(number)Returns the arc cosine, in radians, of number. Returns 0 if number is out of range.
Math.asin(number)Returns the arc sine, in radians, of number. Returns 0 if number is out of range.
Math.atan(number)Returns the arc tangent, in radians, of number.
Math.ceil(number)Returns the least integer that is equal to or greater than number.
Math.cos(number)Returns the cosine of number.
Math.exp(number)Returns the value of enumber. E is Euler's constant-the base of the natural logarithms.
Math.floor(number)Returns the greatest integer that is equal to or less than number.
Math.log(number)Returns the natural logarithm (base e) of number. If number is 0 or less than 0, log returns -1.797693134862316e+308.
Math.max

(number1, number2)

Returns the greater of number1 and number2.
Math.min
(number1, number2)
Returns the lesser of number1 and number2.
Math.pow
(base, exponent)
Returns baseexponent.
Math.random()Returns a pseudo-random number between 0 and 1. Currently available on UNIX platforms only.
Math.round
(number)
Returns the next higher integer value if the fractional part of number is .5 or greater. Returns the next lower integer value if the fractional part of number is less than .5.
Math.sin(number)Returns the sine of number.
Math.sqrt(number)Returns the square root of number. sqrt() always returns 0 if number is out of range.
Math.tan(number)Returns the tangent of number.

The navigator Object

The navigator object refers to the browser itself, and it has properties that you can use to tailor your JavaScript to the browser. There are limitations and bugs associated with the Netscape Navigator that are specific to the platform it is running on or to specific versions of the browser. The navigator object lets you steer around these problems.

The navigator object has no methods and no event handlers. You cannot modify any of its four properties:

appCodeNameThe code name of the browser.
appNameThe name of the browser.
appVersionA string that represents version information about the browser. The information format is version (platform; country) where version is the browser version, platform indicates the platform (Windows, UNIX, and so on), and country is I (international version) or U (domestic United States release).
UserAgentThe value of the user-agent header sent in the HTTP protocol from client to server.

The options Array

The options array is a property of select objects. It allows you to manipulate the options of the select object. Individual options objects are reflections of OPTION elements:

<OPTION>, text to be displayed

The options array has eight properties:

defaultSelectedThe default selection state of an option object. It initially has the value of the OPTION tag's SELECTED attribute. You can change defaultSelected at any time. Doing so has no effect on the appearance of the OPTION element.
indexThe index of an option object in the options array. You cannot change this property.
lengthThe number of entries in the options array. You cannot change this property.
nameThe SELECT element's NAME attribute. All OPTION elements are supposed to be contained in a SELECT element. You can change this property at any time.
selectedA Boolean value that indicates an option object's current selection state. It is true if the option object is selected, and false if it is not selected. You can change this property at any time. Changing this property affects the appearance of the SELECT element immediately.
selectedIndexThe index of the first selected option in the options array; -1 if no option is selected. You can change this property at any time; doing so clears all other options in the options array.
textThe text that follows an option object's OPTION tag. You can change this property, but the display does not reflect the change.
valueThe OPTION tag's VALUE attribute. You can change this property, but the display does not reflect the change. JavaScript returns this property to the server if the user selects the option.

The password Object

A password object is a reflection of an INPUT element with a TYPE attribute of "password":

<INPUT TYPE="password">

The data entered by the user is not visible to the display-each character appears as an asterisk-and it is not visible programatically.

password objects are members of the containing form object's elements array.

A password object has three properties:

defaultValueThe default value for the password object. It is null initially. You may change it at any time. Changing this property has no effect on the display.
nameThe INPUT tag's NAME attribute. You can change it at any time.
valueThe INPUT tag's VALUE attribute. You can change it at any time. Changing this property immediately updates the display, but the display shows it as a string of asterisks. If you set this property, you can read it back, but if the user enters text into the input field, you cannot read it.

A password object has three methods:

blur()Removes focus from the password object.
focus()Moves focus to the password object. When the password object has focus, you can enter a value from JavaScript or the user can enter a value.
select()Highlights the input area of the input field and positions the cursor for user response.

The radio Object

The radio object represents a set of INPUT elements of TYPE "radio" with the same NAME attribute:

<INPUT TYPE="radio" NAME=radioName>

Each button in a radio object is a member of the containing form object's elements array.

A radio object has five properties:

checkedA Boolean value that indicates whether a specific button in the set of radio buttons is checked. You can change this property at any time. Changing it changes the appearance of the buttons immediately.
defaultCheckedA Boolean value that indicates the default state of a specific button in the set of radio buttons. The default state of the button is checked if this property is true. The initial value of this property is the CHECKED attribute of the INPUT tag. You can change this property at any time. Changing it has no effect on the appearance of the buttons.
lengthThe number of radio buttons in the radio object. You cannot change this property.
nameThe text following a specific button's INPUT tag. You can change it at any time.
valueA specific radio button's INPUT tag's VALUE attribute. In the absence of such an attribute, this property is set to "on". JavaScript returns this property to the server if the user selected this specific radio button. The browser does not display this property. You can change this property at any time.

A radio object has one method:

click()Selects the specified radio button. The onClick event handler is not executed.

A radio object has one event handler:

onClickExecuted when the user clicks on the display object.

The reset Object

A reset object is a reflection of an INPUT tag with a TYPE attribute of "reset":

<INPUT TYPE="reset">

reset objects are members of the containing form object's elements array.

A reset object has two properties:

nameThe INPUT tag's NAME attribute. You can change it at any time.
valueThe INPUT tag's VALUE attribute. In the absence of a VALUE attribute, this property is "Reset". You cannot change this property.

A reset object has one method:

click()Simulates a mouse click on the reset button. The onClick event handler is not executed.

A reset object has one event handler:

onClickExecuted when the user clicks on the display object.

The select Object

A select object is a reflection of a SELECT element:

<SELECT><OPTION>...</SELECT>

select objects are members of the containing form object's elements array.

A select object has four roperties:

lengthThe number of OPTION elements within the SELECT element. You cannot change this property.
nameThe SELECT tag's NAME attribute. You can change it at any time.
optionsAn array of the option objects corresponding to the OPTION elements within the SELECT element. You cannot change the elements of this array.
selected-IndexThe index of the first selected option object in the objects array. You can change this property at any time; doing so clears all other options in the display.

A select object has two methods:

blur()Removes focus from the SELECT element. The onBlur event handler is not executed.
focus()Moves focus to the SELECT element. The onFocus event handler is not executed.

A select object has three event handlers:

onBlurExecuted when the user attempts to leave the select field.
onChangeExecuted when the field loses focus and the user has changed the field value.
onFocusExecuted when the display object receives focus if the user tabs to it or clicks on it with the mouse.

The string Object

A string object is a series of characters. You can extract characters in a string, and you can extract pieces of a string, which are called substrings. The string object behaves like a sequence of characters ordered from left to right.

A string object has one property:

lengthThe number of characters in the string object. You cannot change this property.

A string object has 19 methods:

anchor(name)Creates an a document.write() or document.writeln(). The string object contains the text the user will see. name is the anchor element's NAME attribute. An anchor object created with this method becomes a member of the anchors array.
big()Formats the string object as if it were within a BIG element.
blink()Formats the string object as if it were within a BLINK element.
bold()Formats the string object as if it were within a B element.
charAt(index)Returns the character at index into the string object. If index is out of range, charAt() returns an empty string.
fixed()Formats a string object as if it were within a TT element.
fontcolor(color)Formats a string object as if it were within a FONT element with the COLOR attribute set to color.
Fontsize(size)Formats a string object as if it were within a FONT element with the SIZE attribute set to size.
indexOf (searchText)

indexOf (searchText, index)

Searches a string object for an occurrence of searchText, starting at index. If you omit index, the browser assumes a starting index of 0. Returns the index where it finds searchText. If it does not find searchText, it returns -1.
italics()Formats a string object as if it were within an I element.
lastIndexOf (searchText) lastIndexOf (searchText, index) Searches the string object backwards for an occurrence of searchText, starting at index. If you omit index, the browser assumes a starting index of the string object's length minus 1. It returns the index where it finds searchText. If it does not find searchText, it returns -1.
link(href)Creates an anchor element. The string object is the contents of the element, and href is the value of the anchor element's HREF attribute. A link created with this method becomes an element of the links array.
small()Formats a string object as if it were within a SMALL element.
strike()Formats a string object as if it were within a STRIKE element.
sub()Formats a string object as if it were within a SUB element.
Substring (index1, index2)Returns a part of text defined by index1 and index2. If index1 is less than index2, substring() returns the characters in the string object index1 to index2 - 1. If index2 is less than index1, substring() returns the characters in text from index2 to index1 - 1. If index1 and index2 are equal, substring() returns an empty string.
sup()Formats a string object as if it were within a SUP element.
toLowerCase()Returns the text of the string object in lowercase.
toUpperCase()Returns the text of the string object in uppercase.

The submit Object

A submit object is a reflection of an INPUT element with a TYPE attribute of "submit":

<INPUT TYPE="submit">

submit objects are members of the containing form object's elements array.

A submit object has two properties:

nameThe INPUT tag's NAME attribute. You can change it at any time.
valueThe INPUT tag's VALUE attribute. In the absence of a VALUE attribute, this property is "Submit Query". You cannot change this property.

A submit object has one method:

click()Simulates a mouse click on the SUBMIT element. The onClick event handler is not executed.

A submit object has one event handler:

onClickExecuted when the user clicks on the display object.

The text Object

A text object is a reflection of an INPUT element with a TYPE attribute of "text":

<INPUT TYPE="text">

text objects are members of the containing form object's elements array.

A text object has three properties:

defaultValueThe default value for the text object. It is initially the INPUT tag's VALUE attribute. You may change this property at any time. Changing it has no effect on the appearance of text.
nameThe INPUT tag's NAME attribute. You can change it at any time.
valueInitially, the INPUT tag's VALUE attribute. You can change it at any time. The browser immediately updates the display.

A text object has four methods:

blur()Removes focus from the text object. The onBlur event handler is not executed.
focus()Moves focus to the text object. When the text object has focus, the user can enter a value. The onFocus event handler is not executed.
select()Highlights the text object's input area and positions the cursor for user response. The onSelect event handler is not executed.

A text object has four event handlers:

onBlurExecuted when the user attempts to leave the field.
onChangeExecuted when the field loses focus and the user has changed the field value.
onFocusExecuted when the display object receives focus if the user tabs to it or clicks on it with the mouse.
onSelectExecuted when the user selects any of the text in the field.

The textarea Object

A textarea object is a reflection of a TEXTAREA element:

<TEXTAREA>... text to be displayed ... </TEXTAREA>

textarea objects are members of the containing form object's elements array.

A textarea object has three properties:

defaultValueThe default value for the textarea object. Initially, it is the TEXTAREA tag's VALUE attribute. You can change it at any time. Changing it has no effect on the appearance of the textarea object.
nameThe TEXTAREA tag's NAME attribute. You can change it at any time.
valueInitially, the TEXTAREA tag's VALUE attribute. You can change it at any time. The browser immediately updates the display.

A textarea object has three methods:

blur()Removes focus from the textarea object. The onBlur event handler is not executed.
focus()Moves focus to the textarea object. When the textarea object has focus, the user can enter a value.
select()Highlights the input area of the textarea object and positions the cursor for user response.

A textarea object has four event handlers:

onBlurExecuted when the user attempts to leave the field.
onChangeExecuted when the field loses focus and the user has changed the field value.
onFocusExecuted when the display object receives focus if the user tabs to it or clicks on it with the mouse.
onSelectExecuted when the user selects some of the text in the field.

The window Object

The window object is a top-level object that contains a document object, a history object, and a location object. It may also contain a frames array, which is an array of frame objects. The term "window" is somewhat ambiguous. It refers to the entire browser display on the user's screen. The browser can spawn additional displays; those displays are also windows. Each FRAMESET and FRAME element also defines a window.

The browser display window has several components to which the window object's properties and methods refer. One component, the status bar, has two values that you can manipulate: a default message that normally appears, and a transitory message that overrides the default message.

The window object has eight properties:

defaultStatusThe message that appears in the window status bar when nothing else is in the status bar. If you change this property within an onMouseOver event handler, the event handler must return true for defaultStatus to be changed.
lengthThe number of frames. You cannot change this property.
nameThe window's name.
parentA synonym for the window or frame object that contains this window object. You cannot change this property.
selfA synonym for this window object. You cannot change this property.
statusThe transitory message that appears in the window status bar-for example, when a mouseOver event occurs. If you change this property within an onMouseOver event handler, the event handler must return true for status to be changed.
topA synonym for the topmost window that contains frames or nested framesets. You cannot change this property.
windowA synonym for the this window object. You cannot change this property.

The window object has seven methods:

alert(message)Displays message in a dialog box that requires no user decision.
ClearTimeout (timeoutID)Cancels the timeout specified by timeoutID.
close()Closes the window. In event handlers, you must specify a window reference (windowRef.close()). If you do not specify a window reference, the browser assumes you meant document.close().
confirm (message)Displays message in a dialog box that requires the user to select either OK or Cancel. Returns true if the user selects OK and false if the user selects Cancel.
open(URL, windowName, features) Creates a new browser display window. URL is the URL to open in the new window. windowName is a name that a FORM or A element can use in its TARGET attribute. features is a column-delimited list of window options. Do not use spaces. The options are directories-Creates the standard Navigator directory buttons, if true.

height=pixels-Specifies the window height in pixels. pixels must be a positive number.

Location-Creates a location entry field, if true.

Menubar-Creates the menu at the top of the window, if true.

Resizable-Allows the user to resize the window, if true.

Scrollbars-Creates horizontal and vertical scrollbars when the document is larger than the window, if true.

status-Creates the status bar at the bottom of the window, if true.

toolbar-Creates the standard Navigator toolbar, if true.

width=pixels-Specifies the window width in pixels. pixels must be a positive number.

The Boolean options (all options except height and width) are true if included as option, option=1, or option=yes. Boolean options are false if omitted or if included as option=0 or option=no. Exception: if you list no window options and you omit windowName, all options are true.

open() returns a window object reference.

prompt (message)

prompt (message, inputDefault)

Displays a dialog box that displays message and receives user input. InputDefault is the default value. If you do not specify inputDefault, the browser displays the value <undefined>. prompt returns the text entered by the user.
SetTimeout (expression, time)Evaluates expression after time milliseconds. setTimeout returns a timer ID that can be used in a call to clearTimeout().

The window object can have two event handlers:

onLoadExecuted when a window or all frames in a frameset have finished loading.
OnUnloadExecuted when the user exits the window.

Built-in functions

JavaScript provides six built-in functions. These functions are unrelated to the built-in objects.

escape (string)string is a string in the ISO Latin-1 character set. Returns a string. escape() converts nonalphanumeric characters in string to the form %xx, where xx is the hexadecimal representation of the character's value. escape() passes alphanumeric characters in string to the return string intact.
eval (string)string is a string containing a JavaScript statement or expression or sequence of statements. Evaluates string and returns a value.
isNan (value)value is a value returned from parseFloat() or parseInt(). Returns true if value is NaN. NaN is a special value returned by parseFloat() and parseInt() to indicate that the evaluated value is not a number. parseFloat() and parseInt() do not return NaN in Windows platforms.
parseFloat (string)string is a string representing a numric value. Returns the floating-point number that string represents. It stops parsing string when it encounters a character that is not part of a valid numeric expression. parseFloat() returns NaN (not a number), under all platforms except Windows, if it cannot create a valid floating-point number. parseFloat() returns 0 under Windows when it cannot create a valid floating-point number.
parseInt (string) or parseInt (string, radix) string is a string representing a numeric value. radix is a nonnegative integer. Returns the integer that string, in the specified radix, represents. The browser guesses a radix if you omit radix or specify a value of 0. The browser assumes a value of 16 if string begins with 0x, 8 if string begins with 0, and 10 if string begins with any other digit. JavaScript assumes that letters are digits, such as A-F for a radix of 16, when radix is greater than 10. parseInt() returns NaN (not a number), under all platforms except Windows, if it cannot create a valid floating-point number. ParseInt() returns 0 under Windows when it cannot create a valid floating-point number.
Unescape (string)string is a string that contains sequences of "%number", where number is a value from 0 to 255, or "0xnumber", where number is a hexadecimal value from 00 to FF. Returns a string with the escaped values in string converted to ISO Latin-1 characters.