|
|
|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98
APPENDIX A JavaScript 1.2 Language Reference
How This Reference Is Organized
The first part of this reference is organized by object, with properties and methods listed by the object to which they apply. It covers most of the objects included in the Document Object Model supported by JavaScript 1.2. The second part covers independent functions in JavaScript not connected with a particular object, as well as operators in JavaScript.
A Note About JavaScript 1.2
JavaScript 1.2 is designed to interface seamlessly with Netscape Navigator 4.0. New features have been introduced in various areas of the language model, including but not limited to the following:
- Events
- Objects
- Properties
- Methods
Netscape Navigator 4.0 has been coded to support these new features, but earlier versions of Navigator have not. Backward compatibility is, therefore, an issue.
Finally, note that when developing, you can now clearly identify which version of JavaScript youre using. If you dont, your scripts might not work. You identify the version by using the LANGUAGE attribute in the <SCRIPT> tag. The following are some examples:
<SCRIPT LANGUAGE=JavaScript>-Compatible with 2.0 and above
<SCRIPT LANGUAGE=JavaScript1.1">Compatible with 3.0 and above
<SCRIPT LANGUAGE=JavaScript1.2">Compatible with 4.0 and above
The following codes are used next to section headings to indicate where objects, methods, properties, and event handlers are implemented:
- 2Netscape Navigator 2.
- 3Netscape Navigator 3.
- 4Netscape Navigator 4 only. (Thats not to say Navigator 4 works with these items only; Navigator 4 will handle all implementations.)
- IMicrosoft Internet Explorer 4.
NOTE: All the JavaScript information referenced in this appendix is client-side JavaScript; server-side JavaScript is not covered.
The anchor Object [2|3|4|I]
The anchor object reflects an HTML anchor.
Properties
- nameA string value indicating the name of the anchor (not 2|3)
The applet Object [3]
The applet object reflects a Java applet included in a Web page with the <APPLET> tag.
Properties
- nameA string reflecting the NAME attribute of the <APPLET> tag
The area Object [3]
The area object reflects a clickable area defined in an imagemap; area objects appear as entries in the links array of the document object.
Properties
- hashA string value indicating an anchor name from the URL
- hostA string value reflecting the host and domain name portion of the URL
- hostnameA string value indicating the host, domain name, and port number from the URL
- hrefA string value reflecting the entire URL
- pathnameA string value reflecting the path portion of the URL (excluding the host, domain name, port number, and protocol)
- portA string value indicating the port number from the URL
- protocolA string value indicating the protocol portion of the URL, including the trailing colon
- searchA string value specifying the query portion of the URL (after the question mark)
- targetA string value reflecting the TARGET attribute of the <AREA> tag
Methods
- getSelectionGets the current selection and returns this value as a string
Event Handlers
- onDblClickSpecifies JavaScript code to execute when the user double-clicks the area (not implemented on Macintosh; Netscape Navigator 4.0 only) (4)
- onMouseOutSpecifies JavaScript code to execute when the mouse moves outside the area specified in the <AREA> tag
| New Properties with JavaScript 1.2
|
| type
| indicates a MouseOut event
|
| target
| indicates the object to which the event was sent
|
| layer[n]
| where [n] represents x or y, used (with page[n] and screen[n]) to describe the cursor location when the MouseOut event occurred
|
| page[n]
| where [n] represents x or y, used (with layer[n] and screen[n]) to describe the cursor location when the MouseOut event occurred
|
| screen[n]
| where [n] represents x or y, used (with layer[n] and page[n]) to describe the cursor location when the MouseOut event occurred
|
- onMouseOverSpecifies JavaScript code to execute when the mouse enters the area specified in the <AREA> tag
| New Properties with JavaScript 1.2
|
| type
| indicates a MouseOver event
|
| target
| indicates the object to which the event was sent
|
| layer[n]
| where [n] represents x or y, used (with page[n] and screen[n]) to describe the cursor location when the MouseOver event occurred
|
| page[n]
| where [n] represents x or y, used (with layer[n] and screen[n]) to describe the cursor location when the MouseOver event occurred
|
| screen[n]
| where [n] represents x or y, used (with layer[n] and page[n]) to describe the cursor location when the MouseOver event occurred
|
The array Object [3|I]
The array object provides a mechanism for creating arrays and working with them. New arrays are created with arrayName=new Array() or arrayName=new Array(arrayLength).
Properties
- lengthAn integer value reflecting the number of elements in an array
- prototypeUsed to add properties to an array object.
Methods
- concat(arrayname)Combines elements of two arrays and returns a third, one level deep, without altering either of the derivative arrays. (Netscape Navigator 4.0 only)
- join(string)Returns a string containing each element of the array, separated by string. (not I)
- reverse()Reverses the order of an array. (not I)
- slice(arrayName, beginSlice, endSlice)Extracts a portion of some array and derives a new array from it. The beginSlice and endSlice parameters specify the target elements at which to begin and end the slice. (Netscape Navigator 4.0 only)
- sort(function)Sorts an array based on function, which indicates a function defining the sort order. function can be omitted, in which case the sort defaults to dictionary order. Note: sort now works on all platforms.
The button Object [2|3|I]
The button object reflects a pushbutton from an HTML form in JavaScript.
Properties
- enabledA Boolean value indicating whether the button is enabled (not 2|3)
- formA reference to the form object containing the button (not 2|3)
- nameA string value containing the name of the button element
- typeA string value reflecting the TYPE attribute of the <INPUT> tag (not 2|I)
- valueA string value containing the value of the button element
Methods
- click()Emulates the action of clicking the button
- focus()Gives focus to the button (not 2|3)
Event Handlers
- onMouseDownSpecifies JavaScript code to execute when a user presses a mouse button
- onMouseUpSpecifies JavaScript code to execute when the user releases a mouse button
- onClickSpecifies JavaScript code to execute when the button is clicked
- onFocusSpecifies JavaScript code to execute when the button receives focus (not 2|3)
The checkbox Object [2|3|I]
The checkbox object makes a check box in an HTML form available in JavaScript.
Properties
- checkedA Boolean value indicating whether the check box element is checked
- defaultCheckedA Boolean value indicating whether the check box element was checked by default (that is, it reflects the CHECKED attribute)
- enabledA Boolean value indicating whether the check box is enabled (not 2|3)
- formA reference to the form object containing the check box (not 2|3)
- nameA string value containing the name of the check box element
- typeA string value reflecting the TYPE attribute of the <INPUT> tag (not 2|I)
- valueA string value containing the value of the check box element
Methods
- click()Emulates the action of clicking the check box
- focus()Gives focus to the check box (not 2|3)
Event Handlers
- onClickSpecifies JavaScript code to execute when the check box is clicked
- onFocusSpecifies JavaScript code to execute when the check box receives focus (not 2|3)
The combo Object [I]
The combo object reflects a combo field in JavaScript.
Properties
- enabledA Boolean value indicating whether the combo box is enabled (not 2|3)
- formA reference to the form object containing the combo box (not 2|3)
- listCountAn integer reflecting the number of elements in the list
- listIndexAn integer reflecting the index of the selected element in the list
- multiSelectA Boolean value indicating whether the combo field is in multiselect mode
- nameA string value reflecting the name of the combo field
- valueA string containing the value of the combo field
Methods
- addItem(index)Adds an item to the combo field before the item at index
- click()Simulates a click on the combo field
- clear()Clears the contents of the combo field
- focus()Gives focus to the combo field
- removeItem(index)Removes the item at index from the combo field
Event Handlers
- onClickSpecifies JavaScript code to execute when the mouse clicks the combo field
- onFocusSpecifies JavaScript code to execute when the combo field receives focus
The date Object [2|3|I]
The date object provides mechanisms for working with dates and times in JavaScript. Instances of the object can be created with the following syntax:
newObjectName=new Date(dateInfo)
Here, dateInfo is an optional specification of a particular date and can be one of the following:
month day, year hours:minutes:seconds
year, month, day
year, month, day, hours, minutes, seconds
The latter two options represent integer values.
If no dateInfo is specified, the new object represents the current date and time.
Properties
- prototypeProvides a mechanism for adding properties to a date object (not 2)
Methods
- getDate()Returns the day of the month for the current date object as an integer from 1 to 31.
- getDay()Returns the day of the week for the current date object as an integer from 0 to 6 (0 is Sunday, 1 is Monday, and so on).
- getHours()Returns the hour from the time in the current date object as an integer from 0 to 23.
- getMinutes()Returns the minutes from the time in the current date object as an integer from 0 to 59.
- getMonth()Returns the month for the current date object as an integer from 0 to 11 (0 is January, 1 is February, and so on).
- getSeconds()Returns the seconds from the time in the current date object as an integer from 0 to 59.
- getTime()Returns the time of the current date object as an integer representing the number of milliseconds since January 1, 1970 at 00:00:00.
- getTimezoneOffset()Returns the difference between the local time and GMT as an integer representing the number of minutes.
- getYear()Returns the year for the current date object as a two-digit integer representing the year less 1900.
- parse(dateString)Returns the number of milliseconds between January 1, 1970 at 00:00:00 and the date specified in dateString, which should take the following format: (not I)
Day, DD Mon YYYY HH:MM:SS TZN
Mon DD, YYYY
- setDate(dateValue)Sets the day of the month for the current date object. dateValue is an integer from 1 to 31.
- setHours(hoursValue)Sets the hours for the time for the current date object. hoursValue is an integer from 0 to 23.
- setMinutes(minutesValue)Sets the minutes for the time for the current date object. minutesValue is an integer from 0 to 59.
- setMonth(monthValue)Sets the month for the current date object. monthValue is an integer from 0 to 11 (0 is January, 1 is February, and so on).
- setSeconds(secondsValue)Sets the seconds for the time for the current date object. secondsValue is an integer from 0 to 59.
- setTime(timeValue)Sets the value for the current date object. timeValue is an integer representing the number of milliseconds since January 1, 1970 at 00:00:00.
- setYear(yearValue)Sets the year for the current date object. yearValue is an integer greater than 1900.
- toGMTString()Returns the value of the current date object in GMT as a string using Internet conventions in the following form:
Day, DD Mon YYYY HH:MM:SS GMT
- toLocaleString()Returns the value of the current date object in the local time using local conventions.
- UTC(yearValue, monthValue, dateValue, hoursValue, minutesValue, secondsValue)Returns the number of milliseconds since January 1, 1970 at 00:00:00 GMT. yearValue is an integer greater than 1900. monthValue is an integer from 0 to 11. dateValue is an integer from 1 to 31. hoursValue is an integer from 0 to 23. minutesValue and secondsValue are integers from 0 to 59. hoursValue, minutesValue, and secondsValue are optional. (not I)
The document Object [2|3|I]
The document object reflects attributes of an HTML document in JavaScript.
Properties
- alinkColorThe color of active links as a string or a hexadecimal triplet.
- anchorsArray of anchor objects in the order they appear in the HTML document. Use anchors.length to get the number of anchors in a document.
- appletsArray of applet objects in the order they appear in the HTML document. Use applets.length to get the number of applets in a document. (not 2)
- bgColorThe color of the documents background.
- cookieA string value containing cookie values for the current document.
- embedsArray of plugin objects in the order they appear in the HTML document. Use embeds.length to get the number of plug-ins in a document. (not 2|I)
- fgColorThe color of the documents foreground.
- formsArray of form objects in the order the forms appear in the HTML file. Use forms.length to get the number of forms in a document.
- imagesArray of image objects in the order they appear in the HTML document. Use images.length to get the number of images in a document. (not 2|I)
- lastModifiedString value containing the last date of the documents modification.
- linkColorThe color of links as a string or a hexadecimal triplet.
- linksArray of link objects in the order the hypertext links appear in the HTML document. Use links.length to get the number of links in a document.
- locationA string containing the URL of the current document. Use document.URL instead of document.location. This property is expected to disappear in a future release.
- referrerA string value containing the URL of the calling document when the user follows a link.
- titleA string containing the title of the current document.
- URLA string reflecting the URL of the current document. Use instead of document.location. (not I)
- vlinkColorThe color of followed links as a string or a hexadecimal triplet.
Event Handlers
- onMouseDownSpecifies JavaScript code to execute when a user presses a mouse button
- onMouseUpSpecifies JavaScript code to execute when the user releases a mouse button
- onKeyUpSpecifies JavaScript code to execute when the user releases a specific key (Netscape Navigator 4.0 only) (4)
- onKeyPressSpecifies JavaScript code to execute when the user holds down a specific key (Netscape Navigator 4.0 only) (4)
- onKeyDownSpecifies JavaScript code to execute when the user presses a specific key (Netscape Navigator 4.0 only) (4)
- onDblClickSpecifies JavaScript code to execute when the user double-clicks the area (not implemented on Macintosh; Netscape Navigator 4.0 only) (4)
Methods
- captureEvents()Used in a window with frames (along with enableExternalCapture), it specifies that the window will capture all specified events. New in JavaScript 1.2.
- clear()Clears the document window. (not I)
- close()Closes the current output stream.
- open(mimeType)Opens a stream that allows write() and writeln() methods to write to the document window. mimeType is an optional string that specifies a document type supported by Navigator or a plug-in (for example, text/html or image/gif).
- releaseEvents(eventType)Specifies that the current window must release events (as opposed to capture them) so that these events can be passed to other objects, perhaps further on in the event hierarchy. New in JavaScript 1.2.
- routeEvent(event)Sends or routes an event through the normal event hierarchy.
- write()Writes text and HTML to the specified document.
- writeln()Writes text and HTML to the specified document followed by a newline character.
The fileUpload Object [3]
Reflects a file upload element in an HTML form.
Properties
- nameA string value reflecting the name of the file upload element.
- valueA string value reflecting the file upload elements field.
The form Object [2|3|I]
The form object reflects an HTML form in JavaScript. Each HTML form in a document is reflected by a distinct instance of the form object.
Properties
- actionA string value specifying the URL to which the form data is submitted
- elementsArray of objects for each form element in the order in which they appear in the form
- encodingString containing the MIME encoding of the form as specified in the ENCTYPE attribute
- methodA string value containing the method of submission of form data to the server
- targetA string value containing the name of the window to which responses to form submissions are directed
Methods
- reset()Resets the form (not 2|I)
- submit()Submits the form
Event Handlers
- onResetSpecifies JavaScript code to execute when the form is reset. (Not 2|I)
- onSubmitSpecifies JavaScript code to execute when the form is submitted. The code should return a true value to allow the form to be submitted. A false value prevents the form from being submitted.
The frame Object [2|3|I]
The frame object reflects a frame window in JavaScript.
Properties
- framesAn array of objects for each frame in a window. Frames appear in the array in the order in which they appear in the HTML source code.
- onblurA string reflecting the onBlur event handler for the frame. New values can be assigned to this property to change the event handler. (not 2)
- onfocusA string reflecting the onFocus event handler for the frame. New values can be assigned to this property to change the event handler. (not 2)
- parentA string indicating the name of the window containing the frame set.
- selfAn alternative for the name of the current window.
- topAn alternative for the name of the topmost window.
- windowAn alternative for the name of the current window.
Methods
- alert(message)Displays message in a dialog box.
- blur()Removes focus from the frame. (not 2)
- clearInterval(intervalID)Cancels timeouts created with the setInterval method; new in JavaScript 1.2.
- close()Closes the window.
- confirm(message)Displays message in a dialog box with OK and Cancel buttons. Returns true or false based on the button clicked by the user.
- focus()Gives focus to the frame. (not 2)
- open(url,name,features)Opens url in a window named name. If name doesnt exist, a new window is created with that name. features is an optional string argument containing a list of features for the new window. The feature list contains any of the following name-value pairs separated by commas and without additional spaces:
| toolbar=[yes,no,1,0]
| indicates whether the window should have a toolbar
|
| location=[yes,no,1,0]
| indicates whether the window should have a location field
|
| directories=[yes,no,1,0]
| indicates whether the window should have directory buttons
|
| status=[yes,no,1,0]
| indicates whether the window should have a status bar
|
| menubar=[yes,no,1,0]
| indicates whether the window should have menus
|
| scrollbars=[yes,no,1,0]
| indicates whether the window should have scrollbars
|
| resizable=[yes,no,1,0]
| indicates whether the window should be resizable
|
| width=pixels
| indicates the width of the window in pixels
|
| height=pixels
| indicates the height of the window in pixels
|
- print()Prints the contents of a frame or window. This is the equivalent of the user clicking the Print button in Netscape Navigator. New in JavaScript 1.2.
- prompt(message,response)Displays message in a dialog box with a text entry field with the default value of response. The users response in the text entry field is returned as a string.
- setInterval(function, msec, [args])Repeatedly calls a function after the period specified by the msec parameter. New in JavaScript 1.2.
- setInterval(expression, msec)Evaluates expression after the period specified by the msec parameter. New in JavaScript 1.2.
- setTimeout(expression,time)Evaluates expression after time; time is a value in milliseconds. The timeout can be named with the following structure:
name=setTimeOut(expression,time)
- clearTimeout(name)Cancels the timeout with the name name.
Event Handlers
- onBlurSpecifies JavaScript code to execute when focus is removed from a frame (Not 2)
- onFocusSpecifies JavaScript code to execute when focus is removed from a frame (Not 2)
- onMoveSpecifies JavaScript code to execute when the user moves a frame (Netscape Navigator 4.0 only)
- onResizeSpecifies JavaScript code to execute when a user resizes the frame (Netscape Navigator 4.0 only)
The function Object [3]
The function object provides a mechanism for indicating JavaScript code to compile as a function. This is the syntax to use the function object:
functionName=new Function(arg1, arg2, arg3, ..., functionCode)
This is similar to the following:
function functionName(arg1, arg2, arg3, ...) {
functionCode
}
In the former, functionName is a variable with a reference to the function, and the function is evaluated each time its used instead of being compiled once.
Properties
- argumentsAn integer reflecting the number of arguments in a function
- prototypeProvides a mechanism for adding properties to a function object
The hidden Object [2|3|I]
The hidden object reflects a hidden field from an HTML form in JavaScript.
Properties
- nameA string value containing the name of the hidden element
- typeA string value reflecting the TYPE property of the <INPUT> tag (not 2|I)
- valueA string value containing the value of the hidden text element
The history Object [2|3|I]
The history object enables a script to work with the Navigator browsers history list in JavaScript. For security and privacy reasons, the actual content of the list isnt reflected into JavaScript.
Properties
- lengthAn integer representing the number of items on the history list (not I)
Methods
- back()Goes back to the previous document in the history list. (not I)
- forward()Goes forward to the next document in the history list. (not I)
- go(location)Goes to the document in the history list specified by location, which can be a string or integer value. If its a string, it represents all or part of a URL in the history list. If its an integer, location represents the relative position of the document on the history list. As an integer, location can be positive or negative. (not I)
The image Object [3]
The image object reflects an image included in an HTML document.
Properties
- borderAn integer value reflecting the width of the images border in pixels
- completeA Boolean value indicating whether the image has finished loading
- heightAn integer value reflecting the height of an image in pixels
- hspaceAn integer value reflecting the HSPACE attribute of the <IMG> tag
- lowsrcA string value containing the URL of the low-resolution version of the image to load
- nameA string value indicating the name of the image object
- prototypeProvides a mechanism for adding properties as an image object
- srcA string value indicating the URL of the image
- vspaceAn integer value reflecting the VSPACE attribute of the <IMG> tag
- widthAn integer value indicating the width of an image in pixels
Event Handlers
- onKeyUpSpecifies JavaScript code to execute when the user releases a specific key. (Netscape Navigator 4.0 only) (4)
- onKeyPressSpecifies JavaScript code to execute when the user holds down a specific key. (Netscape Navigator 4.0 only) (4)
- onKeyDownSpecifies JavaScript code to execute when the user presses a specific key. (Netscape Navigator 4.0 only) (4)
- onAbortSpecifies JavaScript code to execute if the attempt to load the image is aborted. (not 2)
- onErrorSpecifies JavaScript code to execute if an error occurs while loading the image. Setting this event handler to null suppresses error messages if an error occurs while loading. (not 2)
- onLoadSpecifies JavaScript code to execute when the image finishes loading. (not 2)
The layer Object [4]
The layer object is used to embed layers of content within a page; they can be hidden or not hidden. Either type is accessible through JavaScript code. The most common use for layers is in developing Dynamic HTML (DHTML). With layers, you can create animation or other dynamic content on a page by cycling through the layers you have defined.
Properties
- abovePlaces a layer on top of a newly created layer.
- backgroundUsed to specify a tiled background image of the layer.
- belowPlaces a layer below a newly created layer.
- bgColorSets the background color of the layer.
- clip(left, top, right, bottom)Specifies the visible boundaries of the layer.
- heightSpecifies the height of the layer, expressed in pixels (integer) or by a percentage of the instant layer.
- IDPreviously called NAME. Used to name the layer so that it can be referred to by name and accessed by other JavaScript code.
- leftSpecifies the horizontal positioning of the top-left corner of the layer; used with the Top property.
- page[n]Where [n] is x or y. Specifies the horizontal (x) or vertical (y) positioning of the top-left corner of the layer, in relation to the overall enclosing document. (Note: This is different from the Left and Top properties.)
- parentLayerSpecifies the layer object that contains the present layer.
- SRCSpecifies HTML source to be displayed with the target layer. (This source can also include JavaScript.)
- siblingAboveSpecifies the layer object immediately above the present one.
- siblingBelowSpecifies the layer object immediately below the present one.
- topSpecifies the vertical positioning of the top-left corner of the layer. (Used with the Left property.)
- visibilitySpecifies the visibility of the layer. Three choices are possible: show (visible), hidden (not visible), and inherit (layer inherits the properties of its parent).
- widthSpecifies the width of the layer. Used for wrapping procedures; that is, the width denotes the boundary after which the contents wrap inside the layer.
- z-indexSpecifies the Z-order (or stacking order) of the layer. Used to set the layers position within the overall rotational order of all layers. Expressed as an integer. (Used where there are many layers.)
Events
- onBlurSpecifies JavaScript code to execute when the layer loses focus
- onFocusSpecifies JavaScript code to execute when the layer gains focus
- onLoadSpecifies JavaScript code to execute when a layer is loaded
- onMouseOutSpecifies JavaScript code to execute when the mouse cursor moves off the layer
| New Properties
|
| type
| indicates a MouseOut event
|
| target
| indicates the object to which the event was sent
|
| layer[n]
| where [n] represents x or y, used (with page[n] and screen[n]) to describe the cursor location when the MouseOut event occurred
|
| page[n]
| where [n] represents x or y, used (with layer[n] and screen[n]) to describe the cursor location when the MouseOut event occurred
|
| screen[n]
| where [n] represents x or y, used (with layer[n] and page[n]) to describe the cursor location when the MouseOut event occurred
|
- onMouseoverSpecifies the JavaScript code to execute when the mouse cursor enters the layer
| New Properties with JavaScript 1.2
|
| type
| indicates a MouseOver event
|
| target
| indicates the object to which the event was sent
|
| layer[n]
| where [n] represents x or y, used (with page[n] and screen[n]) to describe the cursor location when the MouseOver event occurred
|
| page[n]
| where [n] represents x or y, used (with layer[n] and screen[n]) to describe the cursor location when the MouseOver event occurred
|
| screen[n]
| where [n] represents x or y, used (with layer[n] and page[n]) to describe the cursor location when the MouseOver event occurred
|
Methods
- captureEvents()Used in a window with frames (along with enableExternalCapture), it specifies that the window will capture all specified events. New in JavaScript 1.2.
- load(source, width)Alters the source of the layer by replacing it with HTML (or JavaScript) from the file specified in source. Using this method, you can also pass a width value (in pixels) to accommodate the new content.
- moveAbove(layer)Places the layer above layer in the stack.
- moveBelow(layer)Places the layer below layer in the stack.
- moveBy(x,y)Alters the position of the layer by the specified values, expressed in pixels.
- moveTo(x,y)Alters the position of the layer (within the containing layer) to the specified coordinates, expressed in pixels.
- moveToAbsolute(x,y)Alters the position of the layer (within the page) to the specified coordinates, expressed in pixels.
- releaseEvents(eventType)Specifies that the current window should release events instead of capturing them so that these events can be passed to other objects, perhaps further on in the event hierarchy. New in JavaScript 1.2.
- resizeBy(width,height)Resizes the layer by the specified values, expressed in pixels.
- resizeTo(width,height)Resizes the layer to the specified height and size, expressed in pixels.
- routeEvent(event)Sends or routes an event through the normal event hierarchy.
The link Object [2|3|I]
The link object reflects a hypertext link in the body of a document.
Properties
- hashA string value containing the anchor name in the URL
- hostA string value containing the host name and port number from the URL
- hostnameA string value containing the domain name (or numerical IP address) from the URL
- hrefA string value containing the entire URL
- pathnameA string value specifying the path portion of the URL
- portA string value containing the port number from the URL
- protocolA string value containing the protocol from the URL (including the colon, but not the slashes)
- searchA string value containing any information passed to a GET CGI-BIN call (such as any information after the question mark)
- targetA string value containing the name of the window or frame specified in the TARGET attribute
Event Handlers
- onMouseDownSpecifies JavaScript code to execute when a user presses a mouse button (JavaScript 1.2 and Netscape Navigator 4.0 only) (4)
- onMouseOutSpecifies JavaScript code to execute when the user moves the mouse cursor out of an object (JavaScript 1.2 and Netscape Navigator 4.0 only) (4)
| New Properties with JavaScript 1.2
|
| Type
| indicates a MouseOut event
|
| target
| indicates the object to which the event was sent
|
| layer[n]
| where [n] represents x or y, used (with page[n] and screen[n]) to describe the cursor location when the MouseOut event occurred
|
| page[n]
| where [n] represents x or y, used (with layer[n] and screen[n]) to describe the cursor location when the MouseOut event occurred
|
| screen[n]
| where [n] represents x or y, used with layer[n] and page[n]) to describe the cursor location when the MouseOut event occurred
|
- onMouseUpSpecifies the JavaScript code to execute when the user releases a mouse button
- onKeyUpSpecifies the JavaScript code to execute when the user releases a specific key (Netscape Navigator 4.0 only) (4)
- onKeyPressSpecifies the JavaScript code to execute when the user holds down a specific key (Netscape Navigator 4.0 only) (4)
- onKeyDownSpecifies the JavaScript code to execute when the user presses a specific key (Netscape Navigator 4.0 only) (4)
- onDblClickSpecifies the JavaScript code to execute when the user double-clicks the area (not implemented on Macintosh; Netscape Navigator 4.0 only) (4)
- moveMouseSpecifies the JavaScript code to execute when the mouse pointer moves over the link (not 2|3)
- onClickSpecifies the JavaScript code to execute when the link is clicked
- onMouseOverSpecifies the JavaScript code to execute when the mouse pointer moves over the hypertext link
| New Properties with JavaScript 1.2
|
| type
| indicates a MouseOver event
|
| target
| indicates the object to which the event was sent
|
| layer[n]
| where [n] represents x or y, used (with page[n] and screen[n]) to describe the cursor location when the MouseOver event occurred
|
| page[n]
| where [n] represents x or y, used (with layer[n] and screen[n]) to describe the cursor location when the MouseOver event occurred
|
| screen[n]
| where [n] represents x or y, used (with layer[n] and page[n]) to describe the cursor location when the MouseOver event occurred
|
The location Object [2|3|I]
The location object reflects information about the current URL.
Properties
- hashA string value containing the anchor name in the URL
- hostA string value containing the host name and port number from the URL
- hostnameA string value containing the domain name (or numerical IP address) from the URL
- hrefA string value containing the entire URL
- pathnameA string value specifying the path portion of the URL
- portA string value containing the port number from the URL
- protocolA string value containing the protocol from the URL (including the colon, but not the slashes)
- searchA string value containing any information passed to a GET CGI-BIN call (such as information after the question mark)
Methods
- reload()Reloads the current document. (not 2|I)
- replace(url)Loads url over the current entry in the history list, making it impossible to navigate back to the previous URL with the Back button (not 2|I)
The math Object [2|3|I]
The math object provides properties and methods for advanced mathematical calculations.
Properties
- EThe value of Eulers constant (roughly 2.718) used as the base for natural logarithms
- LN10The value of the natural logarithm of 10 (roughly 2.302)
- LN2The value of the natural logarithm of 2 (roughly 0.693)
- LOG10EThe value of the base-10 logarithm of e (roughly 0.434)
- LOG2EThe value of the base 2 logarithm of e (roughly 1.442)
- PIThe value of P; used to calculate the circumference and area of circles (roughly 3.1415)
- SQRT1_2The value of the square root of one-half (roughly 0.707)
- SQRT2The value of the square root of two (roughly 1.414)
Methods
- abs(number)Returns the absolute value of number. The absolute value is the value of a number with its sign ignoredfor example, abs(4) and abs(-4) both return 4.
- acos(number)Returns the arc cosine of number in radians.
- asin(number)Returns the arc sine of number in radians.
- atan(number)Returns the arc tangent of number in radians.
- atan2(number1,number2)Returns the angle of the polar coordinate corresponding to the Cartesian coordinate (number1,number2). (Not I)
- ceil(number)Returns the next integer greater than number; in other words, rounds up to the next integer.
- cos(number)Returns the cosine of number, which represents an angle in radians.
- exp(number)Returns the value of E to the power of number.
- floor(number)Returns the next integer less than number; in other words, rounds down to the nearest integer.
- log(number)Returns the natural logarithm of number.
- max(number1,number2)Returns the greater of number1 and number2.
- min(number1,number2)Returns the smaller of number1 and number2.
- pow(number1,number2)Returns the value of number1 to the power of number2.
- random()Returns a random number between zero and 1 (at press time, this method was available only on UNIX versions of Navigator 2.0).
- round(number)Returns the closest integer to number; in other words, rounds to the closest integer.
- sin(number)Returns the sine of number, which represents an angle in radians.
- sqrt(number)Returns the square root of number.
- tan(number)Returns the tangent of number, which represents an angle in radians.
The mimeType Object [3]
The mimeType object reflects a MIME type supported by the client browser.
Properties
- typeA string value reflecting the MIME type
- descriptionA string containing a description of the MIME type
- enabledPluginA reference to plugin object for the plug-in supporting the MIME type
- suffixesA string containing a comma-separated list of file suffixes for the MIME type
The navigator Object [2|3|I]
The navigator object reflects information about the version of browser being used.
Properties
- appCodeNameA string value containing the code name of the client (for example, Mozilla for Netscape Navigator).
- appNameA string value containing the name of the client (for example, Netscape for Netscape Navigator).
- appVersionA string value containing the version information for the client in the following form:
versionNumber (platform; country)
- For example, Navigator 2.0, beta 6 for Windows 95 (international version) would have an appVersion property with the value 2.0b6 (Win32; I).
- languageSpecifies the translation of Navigator (a read-only property). New in JavaScript 1.2.
- mimeTypesAn array of mimeType objects reflecting the MIME types supported by the client browser. (not 2|I)
- platformSpecifies the platform for which Navigator was compiled (for example, Win32, MacPPC, UNIX). New in JavaScript 1.2.
- pluginsAn array of plugin objects reflecting the plug-ins in a document in the order of their appearance in the HTML document. (not 2|I)
- userAgentA string containing the complete value of the user-agent header sent in the HTTP request. The following contains all the information in appCodeName and appVersion:
Mozilla/2.0b6 (Win32; I)
Methods
- javaEnabled()Returns a Boolean value indicating whether Java is enabled in the browser. (not 2|I)
- preference(preference.Name, setValue)In signed scripts, this method enables the developer to set certain browser preferences. Preferences available with this method are the following:
| general.always_load_images
| true/false value that sets whether images are automatically loaded.
|
| security.enable_java
| true/false value that sets whether Java is enabled.
|
| javascript.enabled
| true/false value that sets whether JavaScript is enabled.
|
| browser.enable_style_sheets
| true/false value that sets whether style sheets are enabled.
|
| autoupdate.enabled
| true/false value that sets whether autoinstall is enabled.
|
| network.cookie.cookieBehavior
| (0,1,2) value that sets the manner in which cookies are handled. There are three parameters. 0 accepts all cookies; 1 accepts only those that are forwarded to the originating server; 2 denies all cookies.
|
| network.cookie.warnAboutCookies
| true/false value that sets whether the browser will warn on accepting cookies.
|
The option Object [3]
The option object is used to create entries in a select list by using the following syntax:
optionName=new Option(optionText, optionValue, defaultSelected, selected)
Then the following line is used:
selectName.options[index]=optionName.
Properties
- defaultSelectedA Boolean value specifying whether the option is selected by default
- indexAn integer value specifying the options index in the select list
- prototypeProvides a mechanism to add properties to an option object
- selectedA Boolean value indicating whether the option is currently selected
- textA string value reflecting the text displayed for the option
- valueA string value indicating the value submitted to the server when the form is submitted
The password Object [2|3|I]
The password object reflects a password text field from an HTML form in JavaScript.
Properties
- defaultValueA string value containing the default value of the password element (such as the value of the VALUE attribute)
- enabledA Boolean value indicating whether the password field is enabled (not 2|3)
- formA reference to the form object containing the password field (not 2|3)
- nameA string value containing the name of the password element
- valueA string value containing the value of the password element
Methods
- focus()Emulates the action of focusing in the password field
- blur()Emulates the action of removing focus from the password field
- select()Emulates the action of selecting the text in the password field
Event Handlers
- onBlurSpecifies JavaScript code to execute when the password field loses focus (not 2|3)
- onFocusSpecifies JavaScript code to execute when the password field receives focus (not 2|3)
The plugin Object [2|3|I]
The plugin object reflects a plug-in supported by the browser.
Properties
- nameA string value reflecting the name of the plug-in
- filenameA string value reflecting the filename of the plug-in on the systems disk
- descriptionA string value containing the description supplied by the plug-in
The radio Object [2|3|I]
The radio object reflects a set of radio buttons from an HTML form in JavaScript. To access individual radio buttons, use numeric indexes starting at zero. Individual buttons in a set of radio buttons named testRadio, for example, could be referenced by testRadio[0], testRadio[1], and so on.
Properties
- checkedA Boolean value indicating whether a specific radio button is checked. Can be used to select or deselect a button.
- defaultCheckedA Boolean value indicating whether a specific radio button was checked by default (that is, it reflects the CHECKED attribute). (not I)
- enabledA Boolean value indicating whether the radio button is enabled. (not 2|3)
- formA reference to the form object containing the radio button. (not 2|3)
- lengthAn integer value indicating the number of radio buttons in the set. (not I)
- nameA string value containing the name of the set of radio buttons.
- valueA string value containing the value of a specific radio button in a set (that is, it reflects the VALUE attribute).
Methods
- click()Emulates the action of clicking a radio button
- focus()Gives focus to the radio button (not 2|3)
Event Handlers
- onClickSpecifies the JavaScript code to execute when a radio button is clicked
- onFocusSpecifies the JavaScript code to execute when a radio button receives focus (not 2|3)
The regExp Object [3|I]
The regExp object is relevant to searching for regular expressions. Its properties are set before or after a search is performed. They dont generally exercise control over the search itself, but instead articulate a series of values that can be accessed throughout the search.
Properties
- inputThe string against which a Regular Expression is matched. New in JavaScript 1.2.
- multiline [true, false]Sets whether the search continues beyond line breaks on multiple lines (true) or not (false). New in JavaScript 1.2.
- lastMatchIndicates the characters last matched. New in JavaScript 1.2.
- lastParenIndicates the last matched string that appeared in parentheses. New in JavaScript 1.2.
- leftContextIndicates the string just before the most recently matched Regular Expression. New in JavaScript 1.2.
- rightContextIndicates the remainder of the string, beyond the most recently matched Regular Expression. New in JavaScript 1.2.
- $1,..$9Indicates the last nine substrings in a match; those substrings are enclosed in parentheses. New in JavaScript 1.2.
The Regular Expression Object [3|I]
The Regular Expression object contains the pattern of a Regular Expression.
Parameters
- regexpSpecifies the name of the Regular Expression object. New in JavaScript 1.2.
- patternSpecifies the text of the Regular Expression. New in JavaScript 1.2.
Flags
- iSpecifies that during the Regular Expression search, case is ignored (that is, the search is not case sensitive)
- gSpecifies that during the Regular Expression search, the match (and search) should be global
- giSpecifies that during the Regular Expression search, case is ignored and during the Regular Expression search, the match (and search) should be global
Properties
- global [true,false]Sets the g flag value in code, such as whether the search is global (true) or not (false). New in JavaScript 1.2.
- ignoreCase [true,false]Sets the i flag value in code, such as whether the search is case sensitive (true) or not (false). New in JavaScript 1.2.
- lastIndex(Integer value) Indicates the index position at which to start the next matching procedure (for example, lastIndex == 2). New in JavaScript 1.2.
- source(Read-only) Contains the patterns text. New in JavaScript 1.2.
Methods
- compileCompiles the Regular Expression. This method is usually invoked at script startup, when the Regular Expression is already known and will remain constant. New in JavaScript 1.2.
- exec(str)Executes a search for a Regular Expression within the specified string (str). New in JavaScript 1.2. Note: It uses the same properties as the RegExp object.
- test(str)Executes a search for a Regular Expression and a specified string (str). New in JavaScript 1.2. Note: It uses the same properties as the RegExp object.
The reset Object [2|3|I]
The reset object reflects a reset button from an HTML form in JavaScript.
Properties
- enabledA Boolean value indicating whether the reset button is enabled (not 2|3)
- formA reference to the form object containing the reset button (not 2|3)
- nameA string value containing the name of the reset element
- valueA string value containing the value of the reset element
Methods
- click()Emulates the action of clicking the reset button
- focus()Specifies the JavaScript code to execute when the reset button receives focus (not 2|3)
Event Handlers
- onClickSpecifies the JavaScript code to execute when the reset button is clicked
- onFocusSpecifies the JavaScript code to execute when the reset button receives focus (not 2|3)
The screen Object [4|I]
The screen object describes (or specifies) the characteristics of the current screen.
Properties
- availHeightSpecifies the height of the screen in pixels (minus static display constraints set forth by the operating system). New in JavaScript 1.2.
- availWidthSpecifies the width of the current screen in pixels (minus static display constraints set forth by the operating system). New in JavaScript 1.2.
- heightSpecifies the height of the current screen in pixels. New in JavaScript 1.2.
- widthSpecifies the width of the current screen in pixels. New in JavaScript 1.2.
- pixelDepthSpecifies the number of bits (per pixel) in the current screen. New in JavaScript 1.2.
- colorDepthSpecifies the number of possible colors to display in the current screen. New in JavaScript 1.2.
The select Object [2|3]
The select object reflects a selection list from an HTML form in JavaScript.
Properties
- lengthAn integer value containing the number of options in the selection list.
- nameA string value containing the name of the selection list.
- optionsAn array reflecting each of the options in the selection list in the order they appear. The options property has its own properties:
| defaultSelected
| A Boolean value indicating whether an option was selected by default (that is, it reflects the SELECTED attribute).
|
| index
| An integer value reflecting the index of an option.
|
| length
| An integer value reflecting the number of options in the selection list.
|
| name
| A string value containing the name of the selection list.
|
| selected
| A Boolean value indicating whether the option is selected. Can be used to select or deselect an option.
|
| selectedIndex
| An integer value containing the index of the currently selected option.
|
| text
| A string value containing the text displayed in the selection list for a particular option.
|
| value
| A string value indicating the value for the specified option (that is, it reflects the VALUE attribute).
|
- selectedIndexReflects the index of the currently selected option in the selection list
Methods
- blur()Removes focus from the selection list (not 2|3)
- focus()Gives focus to the selection list (not 2|3)
Event Handlers
- onBlurSpecifies the JavaScript code to execute when the selection list loses focus
- onFocusSpecifies the JavaScript code to execute when focus is given to the selection list
- onChangeSpecifies the JavaScript code to execute when the selected option in the list changes
The string Object [2|3|I]
The string object provides properties and methods for working with string literals and variables.
Properties
- lengthAn integer value containing the length of the string expressed as the number of characters in the string
- prototypeProvides a mechanism for adding properties to a string object (not 2)
Methods
- anchor(name)Returns a string containing the value of the string object surrounded by an A container tag with the NAME attribute set to name.
- big()Returns a string containing the value of the string object surrounded by a BIG container tag.
- blink()Returns a string containing the value of the string object surrounded by a BLINK container tag.
- bold()Returns a string containing the value of the string object surrounded by a B container tag.
- charAt(index)Returns the character at the location specified by index.
- charCodeAt(index)Returns a number representing an ISO-Latin-1 codeset value at the instant index. (Netscape Navigator 4.0 and higher only)
- concat(string2)Combines two strings and derives a third, new string. (Netscape Navigator 4.0 and higher only.)
- fixed()Returns a string containing the value of the string object surrounded by a FIXED container tag.
- fontColor(color)Returns a string containing the value of the string object surrounded by a FONT container tag with the COLOR attribute set to color, which is a color name or an RGB triplet. (not I)
- fontSize(size)Returns a string containing the value of the string object surrounded by a FONTSIZE container tag with the size set to size. (not I)
- fromCharCode(num1, num2, …)Returns a string constructed of ISO-Latin-1 characters. Those characters are specified by their codeset values, which are expressed as num1, num2, and so on.
- indexOf(findString,startingIndex)Returns the index of the first occurrence of findString, starting the search at startingIndex, which is optional; if its not provided, the search starts at the start of the string.
- italics()Returns a string containing the value of the string object surrounded by an I container tag.
- lastIndexOf(findString,startingIndex)Returns the index of the last occurrence of findString. This is done by searching backward from startingIndex. startingIndex is optional and is assumed to be the last character in the string if no value is provided.
- link(href)Returns a string containing the value of the string object surrounded by an A container tag with the HREF attribute set to href.
- match(regular_expression)Matches a Regular Expression to a string. The parameter regular_expression is the name of the Regular Expression, expressed either as a variable or a literal.
- replace(regular_expression, newSubStr)Finds and replaces regular_expression with newSubStr.
- search(regular_expression)Finds regular_expression and matches it to some string.
- slice(beginSlice, [endSlice])Extracts a portion of a given string and derives a new string from that excerpt. beginSlice and endSlice are both zero-based indexes that can be used to grab the first, second, and third character, and so on.
- small()Returns a string containing the value of the string object surrounded by a SMALL container tag.
- split(separator)Returns an array of strings created by splitting the string at every occurrence of separator (not 2|I). split has additional functionality in JavaScript 1.2 and for Navigator 4.0 and higher. That new functionality includes the following elements:
| regex and fixed string splitting
| You can now split the string by both Regular Expression argument and fixed string.
|
| limit count
| You can now add a limit count to prevent including empty elements within the string.
|
| whitespace splitting
| The capability to split on a whitespace (including any whitespace, such as space, tab, newline, and so on).
|
- strike()Returns a string containing the value of the string object surrounded by a STRIKE container tag.
- sub()Returns a string containing the value of the string object surrounded by a SUB container tag.
- substr(start, [length])Used to extract a set number (length) of characters within a string. Use start to specify the location at which to begin this extraction process. New in JavaScript 1.2.
- substring(firstIndex,lastIndex)Returns a string equivalent to the substring beginning at firstIndex and ending at the character before lastIndex. If firstIndex is greater than lastIndex, the string starts at lastIndex and ends at the character before firstIndex. Note: In JavaScript 1.2, x and y are no longer swapped. To get this result, you must specify JavaScript 1.2 with the language attribute within the <SCRIPT> tag.
- sup()Returns a string containing the value of the string object surrounded by a SUP container tag.
- toLowerCase()Returns a string containing the value of the string object with all characters converted to lowercase.
- toUpperCase()Returns a string containing the value of the string object with all characters converted to uppercase.
The submit Object [2|3|I]
The submit object reflects a submit button from an HTML form in JavaScript.
Properties
- enabledA Boolean value indicating whether the submit button is enabled (not 2|3)
- formA reference to the form object containing the submit button (not 2|3)
- nameA string value containing the name of the submit button element
- typeA string value reflecting the TYPE attribute of the <INPUT> tag (not 2|I)
- valueA string value containing the value of the submit button element
Methods
- click()Emulates the action of clicking the submit button
- focus()Gives focus to the submit button (not 2|3)
Event Handlers
- onClickSpecifies the JavaScript code to execute when the submit button is clicked
- onFocusSpecifies the JavaScript code to execute when the submit button receives focus (not 2|3)
The text Object [2|3|I]
The text object reflects a text field from an HTML form in JavaScript.
Properties
- defaultValueA string value containing the default value of the text element (that is, the value of the VALUE attribute)
- enabledA Boolean value indicating whether the text field is enabled (not 2|3)
- formA reference to the form object containing the text field (not 2|3)
- nameA string value containing the name of the text element
- typeA string value reflecting the TYPE attribute of the <INPUT> tag (not 2|I)
- valueA string value containing the value of the text element
Methods
- focus()Emulates the action of focusing in the text field
- blur()Emulates the action of removing focus from the text field
- select()Emulates the action of selecting the text in the text field
Event Handlers
- onBlurSpecifies the JavaScript code to execute when focus is removed from the field
- onChangeSpecifies the JavaScript code to execute when the content of the field is changed
- onFocusSpecifies the JavaScript code to execute when focus is given to the field
- onSelectSpecifies the JavaScript code to execute when the user selects some or all of the text in the field
The textarea Object [2|3|I]
The textarea object reflects a multiline text field from an HTML form in JavaScript.
Properties
- defaultValueA string value containing the default value of the textarea element (that is, the value of the VALUE attribute)
- enabledA Boolean value indicating whether the textarea field is enabled (not 2|3)
- formA reference to the form object containing the textarea field (not 2|3)
- nameA string value containing the name of the textarea element
- typeA string value reflecting the type of the textarea object (not 2|I)
- valueA string value containing the value of the textarea element
Methods
- focus()Emulates the action of focusing in the textarea field
- blur()Emulates the action of removing focus from the textarea field
- select()Emulates the action of selecting the text in the textarea field
Event Handlers
- onKeyUpSpecifies the JavaScript code to execute when the user releases a specific key (Netscape Navigator 4.0 only) (4)
- onKeyPressSpecifies the JavaScript code to execute when the user holds down a specific key (Netscape Navigator 4.0 only) (4)
- onKeyDownSpecifies the JavaScript code to execute when the user presses a specific key (Netscape Navigator 4.0 only) (4)
- onBlurSpecifies the JavaScript code to execute when focus is removed from the field
- onChangeSpecifies the JavaScript code to execute when the content of the field is changed
- onFocusSpecifies the JavaScript code to execute when focus is given to the field
- onSelectSpecifies the JavaScript code to execute when the user selects some or all of the text in the field
The window Object [2|3|I]
The window object is the top-level object for each window or frame and the parent object for the document, location, and history objects.
Properties
- defaultStatusA string value containing the default value displayed in the status bar.
- framesAn array of objects for each frame in a window. Frames appear in the array in the order in which they appear in the HTML source code.
- innerHeight()Specifies the vertical size of the content area (in pixels). New in JavaScript 1.2.
- innerWidth()Specifies the horizontal size of the content area (in pixels). New in JavaScript 1.2.
- lengthAn integer value indicating the number of frames in a parent window. (Not I)
- nameA string value containing the name of the window or frame.
- openerA reference to the window object containing the open() method used to open the current window. (Not 2|I)
- pageXOffsetSpecifies the current x position of the viewable window area (expressed in pixels). New in JavaScript 1.2.
- pageYOffsetSpecifies the current y position of the viewable window area (expressed in pixels). New in JavaScript 1.2.
- parentA string indicating the name of the window containing the frameset.
- personalbar [visible=true,false]Represents the Directories bar in Netscape Navigator and whether its visible. New in JavaScript 1.2.
- scrollbars [visible=true,false]Represents the scrollbars of the instant window and whether they are visible. New in JavaScript 1.2.
- selfAn alternative for the name of the current window.
- statusUsed to display a message in the status bar; its done by assigning values to this property.
- statusbar=[true,false,1,0]Specifies whether the status bar of the target window is visible.
- toolbar=[true,false,1,0]Specifies whether the toolbar of the target window is visible.
- topAn alternative for the name of the topmost window.
- windowAn alternative for the name of the current window.
Methods
- alert(message)Displays message in a dialog box.
- back()Sends the user back to the previous URL stored in the history list. (Simulates a user clicking the Back button in Navigator.) New in JavaScript 1.2.
- blur()Removes focus from the window. On many systems, it sends the window to the background. (not 2|I)
- captureEvents()Used in a window with frames (along with enableExternalCapture), it specifies that the window will capture all specified events.
- clearInterval(intervalID)Cancels timeouts created with the setInterval method. New in JavaScript 1.2.
- close()Closes the window. (not I)
- confirm(message)Displays message in a dialog box with OK and Cancel buttons. Returns true or false based on the button clicked by the user.
- disableExternalCapture()Prevents the instant window with frames from capturing events occurring in pages loaded from a different location. New in JavaScript 1.2.
- enableExternalCapture()Enables the instant window (with frames) to capture events occurring in pages loaded from a different location. New in JavaScript 1.2.
- find([string], [true, false], [true, false])Finds string in the target window. There are two true/false parameters: The first specifies the Boolean state of case sensitivity in the search; the second specifies whether the search is performed backward. New in JavaScript 1.2.
- focus()Gives focus to the window. On many systems, it brings the window to the front. (not 2|I)
- forward()Sends the user to the next URL in the history list. (Simulates a user clicking the Forward button in Navigator.) New in JavaScript 1.2.
- home()Sends the user to the users Home Page URL. (For example, in a default configuration of Netscape Navigator, it sends the user to http://home.netscape.com.) New in JavaScript 1.2.
- moveBy(horizontal, vertical)Moves the window according to the specified values horizontal and vertical. New in JavaScript 1.2.
- moveTo(x, y)Moves the top-left corner of the window to the specified location; x and y are screen coordinates. New in JavaScript 1.2.
- navigator(url)Loads url in the window. (Not 2|3)
- open(url,name,features)Opens url in a window named name. If name doesnt exist, a new window is created with that name. features is an optional string argument containing a list of features for the new window. The feature list contains any of the following name-value pairs separated by commas and without additional spaces(not I)
| toolbar=[yes,no,1,0]
| Indicates whether the window should have a toolbar.
|
| location=[yes,no,1,0]
| Indicates whether the window should have a location field.
|
| directories=[yes,no,1,0]
| Indicates whether the window should have directory buttons.
|
| status=[yes,no,1,0]
| Indicates whether the window should have a status bar.
|
| menubar=[yes,no,1,0]
| Indicates whether the window should have menus.
|
| scrollbars=[yes,no,1,0]
| Indicates whether the window should have scrollbars.
|
| resizable=[yes,no,1,0]
| Indicates whether the window should be resizable.
|
| width=pixels
| Indicates the width of the window in pixels.
|
| alwaysLowered=[yes,no,1,2]
| Indicates (if true) that the window should remain below all other windows. (This feature has varying results on varying window systems.) New in JavaScript 1.2. Note: The script must be signed to use this feature.
|
| alwaysRaised=[yes,no,1,2]
| Indicates (if true) that the window should always remain the top-level window. (This feature has varying results on varying window systems.) New in JavaScript 1.2. Note: The script must be signed to use this feature.
|
| dependent[yes,no,1,2]
| Indicates that the current child window will die (or close) when the parent window does. New in JavaScript 1.2.
|
| hotkeys=[yes,no,1,2]
| Indicates (if true) that most hot keys are disabled within the instant window. New in JavaScript 1.2.
|
| innerWidth=pixels
| Indicates the width (in pixels) of the instant windows content area. New in JavaScript 1.2.
|
| innerHeight=pixels
| Indicates the height (in pixels) of the instant windows content area. New in JavaScript 1.2.
|
| outerWidth=pixels
| Indicates the instant windows horizontal outside width boundary. New in JavaScript 1.2.
|
| outerHeight=pixels
| Indicates the instant windows horizontal outside height boundary. New in JavaScript 1.2.
|
| screenX=pixels
| Indicates the distance that the new window is placed from the left side of the screen (horizontally). New in JavaScript 1.2.
|
| screenY=pixels
| Indicates the distance that the new window is placed from the top of the screen (vertically). New in JavaScript 1.2.
|
| z-lock=[yes,no,1,2]
| Indicates that the instant window does not move through the cycling of the z-order; that is, it doesnt rise above other windows, even if activated. New in JavaScript 1.2. Note: The script must be signed for this feature to work.
|
| height=pixels
| Indicates the height of the window in pixels.
|
- print()Prints the contents of a frame or window. Its the equivalent of the user pressing the Print button in Netscape Navigator. New in JavaScript 1.2.
- prompt(message,response)Displays message in a dialog box with a text entry field with the default value of response. The users response in the text entry field is returned as a string.
- releaseEvents(eventType)Specifies that the current window should release events instead of capturing them so that these events can be passed to other objects, perhaps further on in the event hierarchy. New in JavaScript 1.2.
- resizeBy(horizontal, vertical)Resizes the window, moving from the bottom-right corner. New in JavaScript 1.2.
- resizeTo(outerWidth, outerHeight)Resizes the window, using outerWidth and outerHeight properties. New in JavaScript 1.2.
- routeEvent(event)Sends or routes an event through the normal event hierarchy. New in JavaScript 1.2.
- scrollBy(horizontal, vertical)Scroll the viewing area of the current window by the specified amount. New in JavaScript 1.2.
- scrollTo(x, y)Scrolls the current window to the specified position, calculated in x,y coordinates, starting at the top-left corner of the window. New in JavaScript 1.2.
- setInterval(function, msec, [args])Repeatedly calls a function after the period specified by the msec parameter. New in JavaScript 1.2.
- setInterval(expression, msec)Evaluates expression after the period specified by the msec parameter. New in JavaScript 1.2.
- setTimeout(expression,time)Evaluates expression after time, which is a value in milliseconds. The timeout can be named with the following structure:
name=setTimeOut(expression,time)
- scrollTo(x,y)Scrolls the window to the coordinate x,y. (not 2|I)
- stop()Stops the current download. Its the equivalent of the user pressing the Stop button in Netscape Navigator.
- clearTimeout(name)Cancels the timeout with the name name.
Event Handlers
- onDragDropSpecifies the JavaScript code to execute when the user drops an object onto the window. (Netscape Navigator 4.0 and higher only) (4.0)
- onBlurSpecifies the JavaScript code to execute when focus is removed from a window. (not 2|I)
- onErrorSpecifies the JavaScript code to execute when a JavaScript error occurs while loading a document. It can be used to intercept JavaScript errors. Setting this event handler to null effectively prevents JavaScript errors from being displayed to the user. (not 2|I)
- onFocusSpecifies the JavaScript code to execute when the window receives focus. (not 2|I)
- onLoadSpecifies the JavaScript code to execute when the window or frame finishes loading.
- onMoveSpecifies the JavaScript code to execute when the user moves a window. (Netscape Navigator 4.0 only)
- onResizeSpecifies the JavaScript code to execute when a user resizes the window.
- onUnloadSpecifies the JavaScript code to execute when the document in the window or frame is exited.
Independent Functions, Operators, Variables, and Literals
The following subsections describe the functions, operators, variables, and literals that are built in to JavaScript, without being attached to a specific JavaScript object.
Independent Functions
- escape(character)Returns a string containing the ASCII encoding of character in the form %xx; xx is the numeric encoding of the character. (2|3|I)
- eval(expression)Returns the result of evaluating expression, which is an arithmetic expression. (2|3|I)
- isNaN(value)Evaluates value to see if its NaN. Returns a Boolean value. (2|3|I) (On UNIX platforms, not 2)
- parseFloat(string)Converts string to a floating-point number and returns the value. It continues to convert until it hits a non-numeric character and then returns the result. If the first character cant be converted to a number, the function returns NaN (zero on Windows platforms). (2|3|I)
- parseInt(string,base)Converts string to an integer of base base and returns the value. It continues to convert until it hits a non-numeric character and then returns the result. If the first character cant be converted to a number, the function returns NaN (zero on Windows platforms). (2|3|I)
- taint(propertyName)Adds tainting to propertyName. (3)
- toString()This is a method of all objects. It returns the object as a string or returns [object type] if no string representation exists for the object. (2|3) Note: In JavaScript 1.2, it converts objects and strings into literals.
- unescape(string)Returns a character based on the ASCII encoding contained in string. The ASCII encoding should take the form %integer or hexadecimalValue. (2|3|I)
- untaint(propertyName)Removes tainting from propertyName. (3)
Statements
- breakTerminates a while or for loop and passes program control to the first statement following the loop. (2|3|4) Note: In JavaScript 1.2, break has the added functionality of being able to break out of labeled statements.
- commentUsed to add a comment within the script. This comment is ignored by Navigator. Comments in JavaScript work similarly to those in C. They are enclosed in a /* (start), */ (end) structure. (2|3|4)
- continueTerminates execution of statements in a while or for loop and continues iteration of the loop. (2|3|4) Note: In JavaScript 1.2, continue has added functionality that enables you to continue within labeled statements.
- do while: Sets up a loop that continues to execute statements and code until the condition evaluates to false. New in JavaScript 1.2.
- exportUsed with the import statement. In secure, signed scripts, it enables the developer to export all properties, functions, and variables to another script. New in JavaScript 1.2.
- for([initial-expression]; [condition]; [incremental-expression];))Specifies the opening of a for loop. The arguments are these: initialize a variable (initial-expression), create a condition to test for (condition), and specify an incrementation scheme (incremental-expression). (2|3|4)
- for…inImposes a variable to all properties of an object and executes a block of code for each. (2|3|4)
- function [name]()Declares a function so that it can be referred to or reached by event handlers (or other processes). (2|3|4)
- if…elseA structure used to test whether a certain condition is true. If…else blocks can contain nested statements and functions (and call them) if a condition is either true or false. (2|3|4)
- importUsed with the export statement. In secure, signed scripts, it enables the developer to import all properties, functions, and variables from another script. New in JavaScript 1.2.
- label (labeled statements)Statement that creates a label or pointer to code elsewhere in the script. By calling this label, you redirect the script to the labeled statement.
- newCreates an instance of a user-defined object. (It can also be used to create an instance of built-in objects, inherent to JavaScript, such as new Date.) (2|3|4)
- return [value]Specifies a value to be returned by a given function. For example, return x returns the variable value associated with x. (2|3|4)
- switchEvaluates an expression and attempts to match it to a case pattern or label. If the expression matches the case, trailing statements associated with that label are executed. New in JavaScript 1.2. (Operates similarly to the switch statement in C shell syntax.)
- thisA statement used to refer to a specific object, as shown in this example: [2|3|4]
onClick=javascript:my_function(this.form)
- var [name]Declares a variable by name. (2|3|4)
- whileStatement that begins a while loop. while loops specify that as long as (while) a condition is true, execute some code. (2|3|4)
- withStatement that sets the value for the default object; a method thats similar to creating a global variable with a function. (2|3|4)
Operators
- Assignment Operators: See Table A.1. (2|3|I)
Table A.1 Assignment Operators in JavaScript
|
|
| Operator
| Description
|
|
| =
| assigns the value of the right operand to the left operand
|
| +=
| adds the left and right operands and assigns the result to the left operand
|
| -=
| subtracts the right operand from the left operand and assigns the result to the left operand
|
| *=
| multiplies the two operands and assigns the result to the left operand
|
| /=
| divides the left operand by the right operand and assigns the value to the left operand
|
| %=
| divides the left operand by the right operand and assigns the remainder to the left operand
|
|
- Arithmetic Operators: See Table A.2. (2|3|I)
Table A.2 Arithmetic Operators in JavaScript
|
|
| Operator
| Description
|
|
| +
| adds the left and right operands
|
| -
| subtracts the right operand from the left operand
|
| *
| multiplies the two operands
|
| /
| divides the left operand by the right operand
|
| %
| divides the left operand by the right operand and evaluates to the remainder
|
| ++
| increments the operand by one (can be used before or after the operand)
|
| --
| decreases the operand by one (can be used before or after the operand)
|
| -
| changes the sign of the operand
|
|
- Bitwise OperatorsBitwise operators deal with their operands as binary numbers, but return JavaScript numerical value. (See Table A.3.) (2|3|I)
Table A.3 Bitwise Operators in JavaScript
|
|
| Operator
| Description
|
|
| AND (or &)
| Converts operands to integers with 32 bits, pairs the corresponding bits, and returns one for each pair of ones. Returns zero for any other combination.
|
| OR (or |)
| Converts operands to integers with 32 bits, pairs the corresponding bits, and returns one for each pair when one of the two bits is one. Returns zero if both bits are zero.
|
| XOR (or ^)
| Converts operands to integer with 32 bits, pairs the corresponding bits, and returns one for each pair when only one bit is one. Returns zero for any other combination.
|
| <<
| Converts the left operand to an integer with 32 bits and shifts bits to the left the number of bits indicated by the right operand. Bits shifted off to the left are discarded, and zeros are shifted in from the right.
|
| >>>
| Converts the left operand to an integer with 32 bits and shifts bits to the right the number of bits indicated by the right operand. Bits shifted off to the right are discarded, and zeros are shifted in from the left.
|
| >>
| Converts the left operand to an integer with 32 bits and shifts bits to the right the number of bits indicated by the right operand. Bits shifted off to the right are discarded, and copies of the leftmost bit are shifted in from the left.
|
|
- Logical OperatorsSee Table A.4. (2|3|I)
Table A.4 Logical Operators in JavaScript
|
|
| Operator
| Description
|
|
| &&
| Logical AND. Returns true when both operands are true; otherwise, it returns false.
|
| ||
| Logical OR. Returns true if either operand is true. It returns false only when both operands are false.
|
| !
| Logical NOT. Returns true if the operand is false and false if the operand is true. This is a unary operator and precedes the operand.
|
|
- Comparison OperatorsSee Table A.5. [2|3|I]
Table A.5 Logical (Comparison) Operators in JavaScript
|
|
| Operator
| Description
|
|
| ==
| returns true if the operands are equal
|
| !=
| returns true if the operands are not equal
|
| >
| returns true if the left operand is greater than the right operand
|
| <
| returns true if the left operand is less than the right operand
|
| >=
| returns true if the left operand is greater than or equal to the right operand
|
| <=
| returns true if the left operand is less than or equal to the right operand
|
|
- Conditional OperatorsConditional expressions take one form:
(condition) ? val1 : val2
If condition is true, the expression evaluates to val1; otherwise, it evaluates to val2. (2|3|I)
- String OperatorsThe concatenation operator (+) is one of two string operators. It evaluates to a string combining the left and right operands. The concatenation assignment operator (+=) is also available. (2|3|I)
- The typeof OperatorThe typeof operator returns the type of its single operand. Possible types are object, string, number, boolean, function, and undefined. (3|I)
- The void OperatorThe void operator takes an expression as an operand but returns no value. (3)
- Operator PrecedenceJavaScript applies the rules of operator precedence as follows (from lowest to highest precedence):
- Comma (,)
- Assignment operators (=, +=, -=, *=, /=, %=)
- Conditional (? :)
- Logical OR (||)
- Logical AND (&&)
- Bitwise OR (|)
- Bitwise XOR (^)
- Bitwise AND (&)
- Equality (==, !=)
- Relational (<, <=, >, >=)
- Shift (<<, >>, >>>)
- Addition/subtraction (+, -)
- Multiply/divide/modulus (*, /, %)
- Negation/increment (!, -, ++, --)
- Call, member ((), [])
|