Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
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

Bookmark It

Search this book:
 
Previous Table of Contents Next


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 you’re using. If you don’t, 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:

  2—Netscape Navigator 2.
  3—Netscape Navigator 3.
  4—Netscape Navigator 4 only. (That’s not to say Navigator 4 works with these items only; Navigator 4 will handle all implementations.)
  I—Microsoft 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

  name—A 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

  name—A 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

  hash—A string value indicating an anchor name from the URL
  host—A string value reflecting the host and domain name portion of the URL
  hostname—A string value indicating the host, domain name, and port number from the URL
  href—A string value reflecting the entire URL
  pathname—A string value reflecting the path portion of the URL (excluding the host, domain name, port number, and protocol)
  port—A string value indicating the port number from the URL
  protocol—A string value indicating the protocol portion of the URL, including the trailing colon
  search—A string value specifying the query portion of the URL (after the question mark)
  target—A string value reflecting the TARGET attribute of the <AREA> tag

Methods

  getSelection—Gets the current selection and returns this value as a string

Event Handlers

  onDblClick—Specifies JavaScript code to execute when the user double-clicks the area (not implemented on Macintosh; Netscape Navigator 4.0 only) (4)
  onMouseOut—Specifies 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
  onMouseOver—Specifies 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

  length—An integer value reflecting the number of elements in an array
  prototype—Used 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

  enabled—A Boolean value indicating whether the button is enabled (not 2|3)
  form—A reference to the form object containing the button (not 2|3)
  name—A string value containing the name of the button element
  type—A string value reflecting the TYPE attribute of the <INPUT> tag (not 2|I)
  value—A 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

  onMouseDown—Specifies JavaScript code to execute when a user presses a mouse button
  onMouseUp—Specifies JavaScript code to execute when the user releases a mouse button
  onClick—Specifies JavaScript code to execute when the button is clicked
  onFocus—Specifies 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

  checked—A Boolean value indicating whether the check box element is checked
  defaultChecked—A Boolean value indicating whether the check box element was checked by default (that is, it reflects the CHECKED attribute)
  enabled—A Boolean value indicating whether the check box is enabled (not 2|3)
  form—A reference to the form object containing the check box (not 2|3)
  name—A string value containing the name of the check box element
  type—A string value reflecting the TYPE attribute of the <INPUT> tag (not 2|I)
  value—A 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

  onClick—Specifies JavaScript code to execute when the check box is clicked
  onFocus—Specifies 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

  enabled—A Boolean value indicating whether the combo box is enabled (not 2|3)
  form—A reference to the form object containing the combo box (not 2|3)
  listCount—An integer reflecting the number of elements in the list
  listIndex—An integer reflecting the index of the selected element in the list
  multiSelect—A Boolean value indicating whether the combo field is in multiselect mode
  name—A string value reflecting the name of the combo field
  value—A 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

  onClick—Specifies JavaScript code to execute when the mouse clicks the combo field
  onFocus—Specifies 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

  prototype—Provides 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

  alinkColor—The color of active links as a string or a hexadecimal triplet.
  anchors—Array of anchor objects in the order they appear in the HTML document. Use anchors.length to get the number of anchors in a document.
  applets—Array 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)
  bgColor—The color of the document’s background.
  cookie—A string value containing cookie values for the current document.
  embeds—Array 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)
  fgColor—The color of the document’s foreground.
  forms—Array 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.
  images—Array 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)
  lastModified—String value containing the last date of the document’s modification.
  linkColor—The color of links as a string or a hexadecimal triplet.
  links—Array 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.
  location—A 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.
  referrer—A string value containing the URL of the calling document when the user follows a link.
  title—A string containing the title of the current document.
  URL—A string reflecting the URL of the current document. Use instead of document.location. (not I)
  vlinkColor—The color of followed links as a string or a hexadecimal triplet.

Event Handlers

  onMouseDown—Specifies JavaScript code to execute when a user presses a mouse button
  onMouseUp—Specifies JavaScript code to execute when the user releases a mouse button
  onKeyUp—Specifies JavaScript code to execute when the user releases a specific key (Netscape Navigator 4.0 only) (4)
  onKeyPress—Specifies JavaScript code to execute when the user holds down a specific key (Netscape Navigator 4.0 only) (4)
  onKeyDown—Specifies JavaScript code to execute when the user presses a specific key (Netscape Navigator 4.0 only) (4)
  onDblClick—Specifies 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

  name—A string value reflecting the name of the file upload element.
  value—A string value reflecting the file upload element’s 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

  action—A string value specifying the URL to which the form data is submitted
  elements—Array of objects for each form element in the order in which they appear in the form
  encoding—String containing the MIME encoding of the form as specified in the ENCTYPE attribute
  method—A string value containing the method of submission of form data to the server
  target—A 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

  onReset—Specifies JavaScript code to execute when the form is reset. (Not 2|I)
  onSubmit—Specifies 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

  frames—An 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.
  onblur—A string reflecting the onBlur event handler for the frame. New values can be assigned to this property to change the event handler. (not 2)
  onfocus—A string reflecting the onFocus event handler for the frame. New values can be assigned to this property to change the event handler. (not 2)
  parent—A string indicating the name of the window containing the frame set.
  self—An alternative for the name of the current window.
  top—An alternative for the name of the topmost window.
  window—An 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 doesn’t 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 user’s 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

  onBlur—Specifies JavaScript code to execute when focus is removed from a frame (Not 2)
  onFocus—Specifies JavaScript code to execute when focus is removed from a frame (Not 2)
  onMove—Specifies JavaScript code to execute when the user moves a frame (Netscape Navigator 4.0 only)
  onResize—Specifies 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 it’s used instead of being compiled once.

Properties

  arguments—An integer reflecting the number of arguments in a function
  prototype—Provides 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

  name—A string value containing the name of the hidden element
  type—A string value reflecting the TYPE property of the <INPUT> tag (not 2|I)
  value—A 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 browser’s history list in JavaScript. For security and privacy reasons, the actual content of the list isn’t reflected into JavaScript.

Properties

  length—An 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 it’s a string, it represents all or part of a URL in the history list. If it’s 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

  border—An integer value reflecting the width of the image’s border in pixels
  complete—A Boolean value indicating whether the image has finished loading
  height—An integer value reflecting the height of an image in pixels
  hspace—An integer value reflecting the HSPACE attribute of the <IMG> tag
  lowsrc—A string value containing the URL of the low-resolution version of the image to load
  name—A string value indicating the name of the image object
  prototype—Provides a mechanism for adding properties as an image object
  src—A string value indicating the URL of the image
  vspace—An integer value reflecting the VSPACE attribute of the <IMG> tag
  width—An integer value indicating the width of an image in pixels

Event Handlers

  onKeyUp—Specifies JavaScript code to execute when the user releases a specific key. (Netscape Navigator 4.0 only) (4)
  onKeyPress—Specifies JavaScript code to execute when the user holds down a specific key. (Netscape Navigator 4.0 only) (4)
  onKeyDown—Specifies JavaScript code to execute when the user presses a specific key. (Netscape Navigator 4.0 only) (4)
  onAbort—Specifies JavaScript code to execute if the attempt to load the image is aborted. (not 2)
  onError—Specifies 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)
  onLoad—Specifies 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

  above—Places a layer on top of a newly created layer.
  background—Used to specify a tiled background image of the layer.
  below—Places a layer below a newly created layer.
  bgColor—Sets the background color of the layer.
  clip(left, top, right, bottom)—Specifies the visible boundaries of the layer.
  height—Specifies the height of the layer, expressed in pixels (integer) or by a percentage of the instant layer.
  ID—Previously called NAME. Used to name the layer so that it can be referred to by name and accessed by other JavaScript code.
  left—Specifies 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.)
  parentLayer—Specifies the layer object that contains the present layer.
  SRC—Specifies HTML source to be displayed with the target layer. (This source can also include JavaScript.)
  siblingAbove—Specifies the layer object immediately above the present one.
  siblingBelow—Specifies the layer object immediately below the present one.
  top—Specifies the vertical positioning of the top-left corner of the layer. (Used with the Left property.)
  visibility—Specifies the visibility of the layer. Three choices are possible: show (visible), hidden (not visible), and inherit (layer inherits the properties of its parent).
  width—Specifies 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-index—Specifies the Z-order (or stacking order) of the layer. Used to set the layer’s position within the overall rotational order of all layers. Expressed as an integer. (Used where there are many layers.)

Events

  onBlur—Specifies JavaScript code to execute when the layer loses focus
  onFocus—Specifies JavaScript code to execute when the layer gains focus
  onLoad—Specifies JavaScript code to execute when a layer is loaded
  onMouseOut—Specifies 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
  onMouseover—Specifies 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

  hash—A string value containing the anchor name in the URL
  host—A string value containing the host name and port number from the URL
  hostname—A string value containing the domain name (or numerical IP address) from the URL
  href—A string value containing the entire URL
  pathname—A string value specifying the path portion of the URL
  port—A string value containing the port number from the URL
  protocol—A string value containing the protocol from the URL (including the colon, but not the slashes)
  search—A string value containing any information passed to a GET CGI-BIN call (such as any information after the question mark)
  target—A string value containing the name of the window or frame specified in the TARGET attribute

Event Handlers

  onMouseDown—Specifies JavaScript code to execute when a user presses a mouse button (JavaScript 1.2 and Netscape Navigator 4.0 only) (4)
  onMouseOut—Specifies 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
  onMouseUp—Specifies the JavaScript code to execute when the user releases a mouse button
  onKeyUp—Specifies the JavaScript code to execute when the user releases a specific key (Netscape Navigator 4.0 only) (4)
  onKeyPress—Specifies the JavaScript code to execute when the user holds down a specific key (Netscape Navigator 4.0 only) (4)
  onKeyDown—Specifies the JavaScript code to execute when the user presses a specific key (Netscape Navigator 4.0 only) (4)
  onDblClick—Specifies the JavaScript code to execute when the user double-clicks the area (not implemented on Macintosh; Netscape Navigator 4.0 only) (4)
  moveMouse—Specifies the JavaScript code to execute when the mouse pointer moves over the link (not 2|3)
  onClick—Specifies the JavaScript code to execute when the link is clicked
  onMouseOver—Specifies 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

  hash—A string value containing the anchor name in the URL
  host—A string value containing the host name and port number from the URL
  hostname—A string value containing the domain name (or numerical IP address) from the URL
  href—A string value containing the entire URL
  pathname—A string value specifying the path portion of the URL
  port—A string value containing the port number from the URL
  protocol—A string value containing the protocol from the URL (including the colon, but not the slashes)
  search—A 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

  E—The value of Euler’s constant (roughly 2.718) used as the base for natural logarithms
  LN10—The value of the natural logarithm of 10 (roughly 2.302)
  LN2—The value of the natural logarithm of 2 (roughly 0.693)
  LOG10E—The value of the base-10 logarithm of e (roughly 0.434)
  LOG2E—The value of the base 2 logarithm of e (roughly 1.442)
  PI—The value of P; used to calculate the circumference and area of circles (roughly 3.1415)
  SQRT1_2—The value of the square root of one-half (roughly 0.707)
  SQRT2—The 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 ignored—for 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

  type—A string value reflecting the MIME type
  description—A string containing a description of the MIME type
  enabledPlugin—A reference to plugin object for the plug-in supporting the MIME type
  suffixes—A 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

  appCodeName—A string value containing the code name of the client (for example, “Mozilla” for Netscape Navigator).
  appName—A string value containing the name of the client (for example, “Netscape” for Netscape Navigator).
  appVersion—A 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)”.
  language—Specifies the translation of Navigator (a read-only property). New in JavaScript 1.2.
  mimeTypes—An array of mimeType objects reflecting the MIME types supported by the client browser. (not 2|I)
  platform—Specifies the platform for which Navigator was compiled (for example, Win32, MacPPC, UNIX). New in JavaScript 1.2.
  plugins—An array of plugin objects reflecting the plug-ins in a document in the order of their appearance in the HTML document. (not 2|I)
  userAgent—A 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

  defaultSelected—A Boolean value specifying whether the option is selected by default
  index—An integer value specifying the option’s index in the select list
  prototype—Provides a mechanism to add properties to an option object
  selected—A Boolean value indicating whether the option is currently selected
  text—A string value reflecting the text displayed for the option
  value—A 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

  defaultValue—A string value containing the default value of the password element (such as the value of the VALUE attribute)
  enabled—A Boolean value indicating whether the password field is enabled (not 2|3)
  form—A reference to the form object containing the password field (not 2|3)
  name—A string value containing the name of the password element
  value—A 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

  onBlur—Specifies JavaScript code to execute when the password field loses focus (not 2|3)
  onFocus—Specifies 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

  name—A string value reflecting the name of the plug-in
  filename—A string value reflecting the filename of the plug-in on the system’s disk
  description—A 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

  checked—A Boolean value indicating whether a specific radio button is checked. Can be used to select or deselect a button.
  defaultChecked—A Boolean value indicating whether a specific radio button was checked by default (that is, it reflects the CHECKED attribute). (not I)
  enabled—A Boolean value indicating whether the radio button is enabled. (not 2|3)
  form—A reference to the form object containing the radio button. (not 2|3)
  length—An integer value indicating the number of radio buttons in the set. (not I)
  name—A string value containing the name of the set of radio buttons.
  value—A 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

  onClick—Specifies the JavaScript code to execute when a radio button is clicked
  onFocus—Specifies 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 don’t generally exercise control over the search itself, but instead articulate a series of values that can be accessed throughout the search.

Properties

  input—The 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.
  lastMatch—Indicates the characters last matched. New in JavaScript 1.2.
  lastParen—Indicates the last matched string that appeared in parentheses. New in JavaScript 1.2.
  leftContext—Indicates the string just before the most recently matched Regular Expression. New in JavaScript 1.2.
  rightContext—Indicates the remainder of the string, beyond the most recently matched Regular Expression. New in JavaScript 1.2.
  $1,..$9—Indicates 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

  regexp—Specifies the name of the Regular Expression object. New in JavaScript 1.2.
  pattern—Specifies the text of the Regular Expression. New in JavaScript 1.2.

Flags

  i—Specifies that during the Regular Expression search, case is ignored (that is, the search is not case sensitive)
  g—Specifies that during the Regular Expression search, the match (and search) should be global
  gi—Specifies 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 pattern’s text. New in JavaScript 1.2.

Methods

  compile—Compiles 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

  enabled—A Boolean value indicating whether the reset button is enabled (not 2|3)
  form—A reference to the form object containing the reset button (not 2|3)
  name—A string value containing the name of the reset element
  value—A 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

  onClick—Specifies the JavaScript code to execute when the reset button is clicked
  onFocus—Specifies 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

  availHeight—Specifies the height of the screen in pixels (minus static display constraints set forth by the operating system). New in JavaScript 1.2.
  availWidth—Specifies the width of the current screen in pixels (minus static display constraints set forth by the operating system). New in JavaScript 1.2.
  height—Specifies the height of the current screen in pixels. New in JavaScript 1.2.
  width—Specifies the width of the current screen in pixels. New in JavaScript 1.2.
  pixelDepth—Specifies the number of bits (per pixel) in the current screen. New in JavaScript 1.2.
  colorDepth—Specifies 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

  length—An integer value containing the number of options in the selection list.
  name—A string value containing the name of the selection list.
  options—An 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).
  selectedIndex—Reflects 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

  onBlur—Specifies the JavaScript code to execute when the selection list loses focus
  onFocus—Specifies the JavaScript code to execute when focus is given to the selection list
  onChange—Specifies 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

  length—An integer value containing the length of the string expressed as the number of characters in the string
  prototype—Provides 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 it’s 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

  enabled—A Boolean value indicating whether the submit button is enabled (not 2|3)
  form—A reference to the form object containing the submit button (not 2|3)
  name—A string value containing the name of the submit button element
  type—A string value reflecting the TYPE attribute of the <INPUT> tag (not 2|I)
  value—A 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

  onClick—Specifies the JavaScript code to execute when the submit button is clicked
  onFocus—Specifies 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

  defaultValue—A string value containing the default value of the text element (that is, the value of the VALUE attribute)
  enabled—A Boolean value indicating whether the text field is enabled (not 2|3)
  form—A reference to the form object containing the text field (not 2|3)
  name—A string value containing the name of the text element
  type—A string value reflecting the TYPE attribute of the <INPUT> tag (not 2|I)
  value—A 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

  onBlur—Specifies the JavaScript code to execute when focus is removed from the field
  onChange—Specifies the JavaScript code to execute when the content of the field is changed
  onFocus—Specifies the JavaScript code to execute when focus is given to the field
  onSelect—Specifies 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

  defaultValue—A string value containing the default value of the textarea element (that is, the value of the VALUE attribute)
  enabled—A Boolean value indicating whether the textarea field is enabled (not 2|3)
  form—A reference to the form object containing the textarea field (not 2|3)
  name—A string value containing the name of the textarea element
  type—A string value reflecting the type of the textarea object (not 2|I)
  value—A 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

  onKeyUp—Specifies the JavaScript code to execute when the user releases a specific key (Netscape Navigator 4.0 only) (4)
  onKeyPress—Specifies the JavaScript code to execute when the user holds down a specific key (Netscape Navigator 4.0 only) (4)
  onKeyDown—Specifies the JavaScript code to execute when the user presses a specific key (Netscape Navigator 4.0 only) (4)
  onBlur—Specifies the JavaScript code to execute when focus is removed from the field
  onChange—Specifies the JavaScript code to execute when the content of the field is changed
  onFocus—Specifies the JavaScript code to execute when focus is given to the field
  onSelect—Specifies 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

  defaultStatus—A string value containing the default value displayed in the status bar.
  frames—An 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.
  length—An integer value indicating the number of frames in a parent window. (Not I)
  name—A string value containing the name of the window or frame.
  opener—A reference to the window object containing the open() method used to open the current window. (Not 2|I)
  pageXOffset—Specifies the current x position of the viewable window area (expressed in pixels). New in JavaScript 1.2.
  pageYOffset—Specifies the current y position of the viewable window area (expressed in pixels). New in JavaScript 1.2.
  parent—A string indicating the name of the window containing the frameset.
  personalbar [visible=true,false]—Represents the Directories bar in Netscape Navigator and whether it’s 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.
  self—An alternative for the name of the current window.
  status—Used to display a message in the status bar; it’s 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.
  top—An alternative for the name of the topmost window.
  window—An 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 user’s 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 doesn’t 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 window’s content area. New in JavaScript 1.2.
innerHeight=pixels Indicates the height (in pixels) of the instant window’s content area. New in JavaScript 1.2.
outerWidth=pixels Indicates the instant window’s horizontal outside width boundary. New in JavaScript 1.2.
outerHeight=pixels Indicates the instant window’s 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 doesn’t 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. It’s 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 user’s 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. It’s the equivalent of the user pressing the Stop button in Netscape Navigator.
  clearTimeout(name)—Cancels the timeout with the name name.

Event Handlers

  onDragDrop—Specifies the JavaScript code to execute when the user drops an object onto the window. (Netscape Navigator 4.0 and higher only) (4.0)
  onBlur—Specifies the JavaScript code to execute when focus is removed from a window. (not 2|I)
  onError—Specifies 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)
  onFocus—Specifies the JavaScript code to execute when the window receives focus. (not 2|I)
  onLoad—Specifies the JavaScript code to execute when the window or frame finishes loading.
  onMove—Specifies the JavaScript code to execute when the user moves a window. (Netscape Navigator 4.0 only)
  onResize—Specifies the JavaScript code to execute when a user resizes the window.
  onUnload—Specifies 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 it’s 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 can’t 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 can’t 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

  break—Terminates 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.
  comment—Used 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)
  continue—Terminates 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.
  export—Used 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…in—Imposes 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…else—A 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)
  import—Used 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.
  new—Creates 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)
  switch—Evaluates 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.)
  this—A 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)
  while—Statement that begins a while loop. while loops specify that as long as (while) a condition is true, execute some code. (2|3|4)
  with—Statement that sets the value for the default object; a method that’s 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 Operators—Bitwise 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 Operators—See 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 Operators—See 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 Operators—Conditional 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 Operators—The 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 Operator—The typeof operator returns the type of its single operand. Possible types are object, string, number, boolean, function, and undefined. (3|I)
  The void Operator—The void operator takes an expression as an operand but returns no value. (3)
  Operator Precedence—JavaScript 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 ((), [])


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.