window | NN 2 IE 3 DOM n/a
The window object represents the browser window or frame in which document content is displayed. The window object plays a vital role in scripting when scripts must communicate with document objects located in other frames or subwindows. Managing multiple windows can be tricky business because of the transient nature of cross-window references. Strict interpretation of HTML and XHTML standards frowns upon multiple windows, and many confused users may agree.
Although the W3C DOM Level 2 does not provide in-depth specifications for the window object (a window, after all, is outside the scope of document markup), it nevertheless indicates possible future hooks through what it calls "view" objects. Thus, the Netscape 6 document.defaultView property returns the document's window; the Netscape 6 window object also takes on the method of the ViewCSS object to gain the DOM's getComputedStyle( ) method.
The window object has been scriptable since the beginning and bears a considerable legacy of properties and methods. Many of these features are browser-specific, so observe compatibility ratings carefully before adopting a particular object feature.
Object Model Reference
    window
    self
    top
    parent
Object-Specific Event Handler Properties

Handler | NN | IE/Windows | IE/Mac | DOM
onafterprint | n/a | 5 | n/a | n/a
onbeforeprint | n/a | 5 | n/a | n/a
onbeforeunload | n/a | 4 | 4 | n/a
onblur | 3 | 4 | 4 | n/a
ondragdrop | 4 | n/a | n/a | n/a
onerror | 3 | 4 | 4 | n/a
onfocus | 3 | 4 | 4 | n/a
onhelp | n/a | 4 | 4 | n/a
onload | 2 | 3 | 3.01 | n/a
onmove | 4 | 5.5 | n/a | n/a
onresize | 4 | 4 | 4 | n/a
onscroll | n/a | 4 | 4 | n/a
onunload | 2 | 4 | 4 | n/a

clientInformation | NN n/a IE 4 DOM n/a
| Read-only
Returns the navigator object. The navigator object is named after a specific browser brand; the clientInformation property is a nondenominational way of accessing important environment variables that have historically been available through properties and methods of the navigator object (discussed separately earlier in this chapter as its own object). In Internet Explorer, you can substitute window.clientInformation for any reference that begins with navigator.
Example
    if (parseInt(window.clientInformation.appVersion) >= 4) {
        // process code for IE 4 or later
    }
Value
The navigator object.
Default
The navigator object.

clipboardData | NN n/a IE 5(Win) DOM n/a
| Read-only
Returns the clipboardData object, discussed separately earlier in this chapter as its own object. The object (accessible as a property of a window or frame object) is a temporary container that scripts in IE 5 and later for Windows can use to transfer text data, particularly during script-controlled operations that simulate cutting, copying, and pasting, or that control dragging.
Example
    var rng = document.selection.createRange( );
    clipboardData.setData("Text",rng.text);
Value
The clipboardData object.
Default
The clipboardData object.

closed | NN 3 IE 4 DOM n/a
| Read-only
This is the Boolean value that says whether the referenced window is closed. A value of true means the window is no longer available for referencing its objects or script components. This is used most often to check whether a user has closed a subwindow generated by the window.open( ) method.
Example
    if (!newWindow.closed) {
        newWindow.document.close( );
    }
Value
Boolean value: true | false.
Default
None.

Components, content, controllers |
See appCore.

crypto, pkcs11 | NN 6 IE n/a DOM n/a
| Read-only
Return references to objects associated with Mozilla public-key cryptography internals. For more details on this subject, visit http://www.mozilla.org/projects/security/.

defaultStatus | NN 2 IE 3 DOM n/a
| Read/Write
Specifies the default message displayed in the browser window's status bar when no browser loading activity is occurring. To temporarily change the message (during mouse rollovers, for example), set the window's status property. Most scriptable browsers and versions have difficulty managing the setting of the defaultStatus property. Expect odd behavior.
Example
    window.defaultStatus = "Make it a great day!";
Value
Any string value.
Default
None.

dialogArguments | NN n/a IE 4 DOM n/a
| Read-only
This is the string or other data type passed as extra arguments to a modal dialog window created with the window.showModalDialog( ) or (in IE 5 and later for Windows only) window.showModelessDialog( ) methods. This property is best accessed by a script in the document displayed in the dialog window in order to retrieve whatever data is passed to the new window as arguments. It is up to your script to parse the data if you include more than one argument nugget separated by whatever argument delimiter you choose.
Example
    // in dialog window
    var allArgs = window.dialogArguments;
    var firstArg = allArgs.substring(0, allArgs.indexOf(";"));
Value
String, number, array, or object.
Default
None.

dialogHeight, dialogWidth | NN n/a IE 4(Win) DOM n/a
| Read/Write
Specify the height and width values of a modal dialog window created with the showModalDialog( ) and showModelessDialog( ) methods. Although Internet Explorer does not balk at modifying these properties (in a script running in the modal dialog window), the changed values are generally not reflected in a resized dialog window. Initial values are set as parameters to the dialog-opening methods.
Example
    var outerWidth = window.dialogWidth;
Value
String, including the unit value (e.g., 520px).
Default
None.

dialogLeft, dialogTop | NN n/a IE 4 DOM n/a
| Read/Write
Indicate the offset distance of the left and top edges of a modal dialog window (created with the showModalDialog( ) and showModelessDialog( ) methods) relative to the top-left corner of the video screen. Although Internet Explorer does not balk at modifying these properties (in a script running in the modal dialog window), the changed values are generally not reflected in a repositioned dialog window. Initial values are set as parameters to the dialog methods.
Example
    var outerLeft = window.dialogLeft;
Value
String, including the unit value (e.g., 80px).
Default
None.

directories, locationbar, menubar, personalbar, scrollbars, statusbar, toolbar | NN 4 IE n/a DOM n/a
| Read-only
Return references to the Navigator browser window feature (the directories property is new for Netscape 6). See the discussion of the directories (et al.) objects earlier in this chapter for how to control the visibility of these window features with signed scripts.
Example
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite")
    window.statusbar.visible = "false";
    netscape.security.PrivilegeManager.revertrivilege("UniversalBrowserWrite")
Value
Respective object references.
Default
None.

document | NN 2 IE 3 DOM 2
| Read-only
Returns a reference to the document object contained by the window. In browsers that offer W3C DOM document tree support, this property points more specifically to the root HTMLDocument node for the document tree loaded in the window. The W3C DOM even describes this property as a member of one of its View objects (analogous to a browser window). This is the property that lets scripts references to document methods and content begin with the word document.
Example
    var oneElem = document.getElementById("myP");
Value
Reference to the root document object.
Default
Reference to the root document object.

event | NN n/a IE 4 DOM n/a
| Read-only
Internet Explorer's event model generates an event object for each user or system event. This event object is a property of the window object. For details about the IE event object, see Chapter 6 and the listing of the event object in this chapter.
Example
    if (event.altKey) {
        // handle case of Alt key down
    }
Value
event object reference.
Default
None.

external | NN n/a IE 4(Win) DOM n/a
| Read-only
Returns a reference to the external object, which provides access to lower-level functionality of the browser engine (security permissions willing). See the discussion of the external object earlier in this chapter.
Example
    external.AddFavorite("http://www.dannyg.com", "Danny Home Page");
Value
external object reference.
Default
external object reference.

frameElement | NN n/a IE 5.5(Win) DOM n/a
| Read-only
If the current window is a member of a frameset or is an iframe, the frameElement property returns a reference to the frame or iframe element object (distinct from the frame-as-window object). Security restrictions, however, can impede script access to this property.
Example
    var frameID = window.frameElement.id;
Value
frame or iframe object reference; or null.
Default
null.

frames[ ] | NN 2 IE 3 DOM n/a
| Read-only
Returns a collection (array) of window objects that are implemented as frames or iframes in the current window. For a frameset's parent or top window, the array contains references to first-generation frame windows. Index values can be zero-based integers (in source code order) or the identifier assigned to the name attribute of the frame element.
Example
    parent.frames[1].myFunc( );
Value
Array of frame (window) object references.
Default
Array of length zero.

history | NN 2 IE 3 DOM n/a
| Read-only
Contains the history object for the current window or frame. For details, see the discussion of the history object.
Example
    if (self.history.length > 4) {
        ...
    }
Value
history object reference.
Default
Current history object.

innerHeight, innerWidth | NN 4 IE n/a DOM n/a
| Read/Write
Specify the pixel measure of the height and width of the content region of a browser window or frame. This area is where the document content appears, exclusive of all window "chrome." For comparable values in IE, see the body element object.
Example
    window.innerWidth = 600;
    window.innerHeight = 400;
Value
Integer.
Default
None.

length | NN 6 IE 4 DOM n/a
| Read-only
Specifies the number of frames (if any) nested within the current window. This value is the same as that returned by window.frames.length. When no frames are defined for the window, the value is zero.
Example
    if (window.length > 0) {
        ...
    }
Value
Integer.
Default
0

location | NN 2 IE 3 DOM n/a
| Read/Write
Returns a location object containing URL details of the document currently loaded in the window or frame. To navigate to another page, you assign a URL to the location.href property (or see the navigate( ) method for an IE-only alternative). See the location object.
Example
    top.location.href = "index.html";
Value
A full or relative URL as a string.
Default
Current location object.

locationbar |
See directories.

menubar |
See directories.

name | NN 2 IE 3 DOM n/a
| Read/Write
This is the identifier associated with a frame or subwindow for use as the value assigned to target attributes or as script references to the frame/subwindow. For a frame, the value is usually assigned via the name attribute of the frame tag, but it can be modified by a script if necessary. The name of a subwindow is assigned as a parameter to the window.open( ) method. The primary browser window does not have a name by default, but you can assign one via script if you need a subwindow to target a link or form back to the main window.
Example
    if (parent.frames[1].name == "main") {
        ...
    }
Value
Case-sensitive identifier that follows the rules of identifier naming: it may contain no whitespace, cannot begin with a numeral, and should avoid punctuation except for the underscore character.
Default
None.

navigator | NN 6 IE 4 DOM n/a
| Read-only
Returns a reference to the navigator object. Since the window reference is optional, syntax without the window reference works on all scriptable versions of Internet Explorer and Navigator. See the navigator object.
Example
    var theBrowser = navigator.appName;
Value
navigator object reference.
Default
navigator object.

offscreenBuffering | NN n/a IE 4 DOM n/a
| Read/Write
Indicates whether the browser should use offscreen buffering to improve path animation performance. Although the property is implemented in IE 5 for Macintosh, it is unclear that it offers any functionality. Recent versions of IE for Windows connect this property to the DirectX ActiveX control. When the document loads, the property is set to auto. After that, a script may turn buffering on and off by assigning a Boolean value to this property.
Example
    window.offscreenBuffering = "true";
Value
Boolean value: true | false.
Default
auto

opener | NN 3 IE 3 DOM n/a
| Read/Write
This is an object reference to the window (or frame) that used a window.open( ) method to generate the current window. This property allows subwindows to assemble references to objects, variables, and functions in the originating window. To access document objects in the creating window, a reference can begin with opener and work its way through the regular document object hierarchy from there, as shown in the left side of the following example statement. The relationship between the opening window and the opened window is not strictly parent-child. The term "parent" has other connotations in scripted window and frame references. IE's dialog windows (the showModalDialog( ) and showModelessDialog( ) windows) do not support this property. Values between the main and dialog windows must be passed at creation time and via the dialog window's returnValue property upon closing.
Example
    opener.document.forms[0].importedData.value = document.forms[0].entry.value;
Value
window object reference.
Default
None.

outerHeight, outerWidth | NN 4 IE n/a DOM n/a
| Read/Write
Specify the pixel measure of the height and width of the browser window or frame, including (for the top window) all tool bars, scoll bars, and other visible window "chrome." IE offers no equivalent properties.
Example
    window.outerWidth = 80;
    window.outerHeight = 600;
Value
Integer.
Default
None.

pageXOffset, pageYOffset | NN 4 IE n/a DOM n/a
| Read-only
Specify the pixel measure of the amount of the page's content that has been scrolled upward and/or to the left. For example, if a document has been scrolled so that the topmost 100 pixels of the document (the "page") are not visible because the window is scrolled, the pageYOffset value for the window is 100. When a document is not scrolled, both values are zero.
Example
    var vertScroll = self.pageYOffset;
Value
Integer.
Default
0

parent | NN 2 IE 3 DOM n/a
| Read-only
Returns a reference to the parent window object whose document defined the frameset in which the current frame is specified. Use parent in building a reference from one child frame to variables or methods in the parent document or to variables, methods, and objects in another child frame. For example, if a script in one child frame must reference the content of a text input form element in the other child frame (named "content"), the reference would be:
    parent.content.document.forms[0].entryField.value
For more deeply nested frames, you can access the parent of a parent with syntax such as: parent.parent.frameName.
Example
    parent.frames[1].document.forms[0].companyName.value = "MegaCorp";
Value
window object reference.
Default
Current window object reference.

personalbar |
See directories.

pkcs11 |
See crypto.

prompter |
See appCore.

returnValue | NN n/a IE 4(Win)/5(Mac) DOM n/a
| Read/Write
A value to be returned to the main window when an IE dialog window (generated by showModalDialog( ) method only) closes. The value assigned to this property in a script running in the dialog window becomes the value returned by the showModalDialog( ) method in the main window. For example, the document in the modal dialog window may have a statement that sets the returnValue property with information from the dialog:
    window.returnValue = window.document.forms[0].userName.value;
The dialog is created in the main document with a statement like the following:
    var userName = showModalDialog("userNamePrompt.html");
Whatever value is assigned to returnValue in the dialog is then assigned to the userName variable when the dialog box closes and script execution continues.
Value
Any scriptable data type.
Default
None.

screen | NN 6 IE 4 DOM n/a
| Read-only
Returns a reference to the screen object. Since the window reference is optional, syntax without the window reference works on all scriptable versions of Internet Explorer and Navigator.
Example
    var howHigh = screen.availHeight;
Value
screen object reference.
Default
screen object.

screenLeft, screenTop | NN n/a IE 5(Win) DOM n/a
| Read-only
Return pixel coordinates of the top-left corner of the browser content area relative to the top-left corner of the screen. A maximized browser window returns a screenLeft value of 0, but the screenTop value varies with the complement of toolbars the user chooses to display. Use window.moveTo( ) to change the window position.
Example
    var fromTheTop = window.screenTop;
Value
Integer.
Default
User-dependent

screenX, screenY | NN 6 IE n/a DOM n/a
| Read/Write
Return pixel coordinates of the top-left corner of the entire browser window (including "chrome") relative to the top-left corner of the screen. A browser window maximized under Windows returns screenX and screenY values of -4 because the chrome extends slightly beyond the screen display. You can adjust the window location through these properties or the window.moveTo( ) method.
Example
    var fromTheTop = window.screenY;
Value
Integer.
Default
User-dependent.

scrollX, scrollY | NN 6 IE n/a DOM n/a
| Read-only
Return the pixel distance the window is scrolled along the horizontal (scrollX) and vertical (scrollY) axes. To determine these values in IE, you must take into account compatibility mode settings in IE 6 (see the DOCTYPE element in Chapter 8). In backward compatibility mode and in IE for Macintosh, use the document.body.scrollLeft and document.body.scrollTop properties. In IE 6 standards compatibility mode (where document.compatMode == "CSS1Compat"), use document.body.parentNode.scrollLeft and document.body.parentNode.scrollTop to get the scroll values of the html element.
Example
    var scrolledDown = window.scrollY;
Value
Integer.
Default
0

scrollbars |
See directories.

self | NN 2 IE 3 DOM n/a
| Read-only
This is a reference to the current window or frame. This property is synonymous with window, but is sometimes used to improve clarity in a complex script that refers to many windows or frames. Never use the reference window.self to refer to the current window or frame because some browser versions get confused with the reference.
Example
    self.focus( );
Value
window object reference.
Default
Current window.

status | NN 2 IE 3 DOM n/a
| Read/Write
Specifies the text of the status bar of the browser window. Setting the status bar to some message is recommended only for temporary messages, such as for mouse rollovers atop images, areas, or links. Double or single quotes in the message must be escaped (\'). Many users don't notice incidental text in the status bar, so avoid putting mission-critical information there. Temporary messages conflict with browser-driven use of the status bar for loading progress and other purposes. To set the default status bar message (when all is at rest), see the defaultStatus property.
Example
    <...onmouseover="window.status='Table of Contents';return true"
    onmouseout = "window.status = '';return true">
Value
String.
Default
Empty string.

statusbar |
See directories.

toolbar |
See directories.

top | NN 2 IE 3 DOM n/a
| Read-only
This is an object reference to the browser window. Script statements from inside nested frames can refer to the browser window properties and methods or to variables or functions stored in the document loaded in the topmost position. Do not begin a reference with window.top, just top. To replace a frameset with a new document that occupies the entire browser window, assign a URL to the top.location.href property.
Example
    top.location.href = "tableOfContents.html";
Value
window object reference.
Default
Browser window.

window | NN 2 IE 3 DOM n/a
| Read-only
This is an object reference to the browser window.
Example
    if (window == top) {
        // load a frameset
        location.href = "mainFrameset.html";
    }
Value
window object reference.
Default
Browser window.

addEventListener( ) | NN 6 IE n/a DOM n/a
addEventListener("eventType", listenerFunction, useCapture) |
Although the window object as we know it is not officially part of the W3C DOM, Netscape 6 implements this W3C DOM event model method for the window object. See the addEventListener( ) method discussion among the shared methods described earlier in this chapter.

alert( ) | NN 2 IE 3 DOM n/a
alert("message") |
Displays an alert dialog box with a message of your choice. Script execution halts while the dialog box appears. A single button lets the user close the dialog. The title bar of the window (and the "JavaScript Alert" legend in earlier browser versions) cannot be altered by script.
Parameters

- Any string.

Returned Value
None.

attachEvent( ) | NN n/a IE 5(Win) DOM n/a
attachEvent("eventName", functionReference) |
This IE event model method, shared among all element objects, is also a member of the window object. See the attachEvent( ) method discussion among the shared methods described earlier in this chapter.

back( ) | NN 4 IE n/a DOM n/a
Navigates one step backward through the history list of the window or frame. You may prefer the cross-browser history.back( ) method.
Parameters
None.
Returned Value
None.

blur( ) | NN 3 IE 4 DOM n/a
Removes focus from the window and fires an onBlur event (in IE). No other element necessarily receives focus as a result, but if another IE window is open at the time, the current window moves to the rear of the stack.
Parameters
None.
Returned Value
None.

captureEvents( ) | NN 4 IE n/a DOM n/a
captureEvents(eventTypeList) |
Instructs the browser to grab events of a specific type before they reach their intended target objects. The object invoking this method must then have event handlers defined for the given event types to process the event. Although this method is part of the Navigator 4 event model, it continues to be supported in Netscape 6, creating the equivalent of a W3C DOM capture-mode event listener for the document object. Continue to use this method if you must support Navigator 4, but migrate new code to the W3C DOM event listener syntax as described in Chapter 6.
Parameters

eventTypeList

  A comma-separated list of case-sensitive event types as derived from the available Event object constants, such as Event.CLICK or Event.MOUSEMOVE.

Returned Value
None.

clearInterval( ) | NN 4 IE 4 DOM n/a
clearInterval(intervalID) |
Turns off the interval looping action referenced by the intervalID parameter. See setInterval( ) for how to initiate such a loop.
Parameters

- An integer created as the return value of a setInterval( ) method.

Returned Value
None.

clearTimeout( ) | NN 2 IE 3 DOM n/a
clearTimeout(timeoutID) |
Turns off the timeout delay counter referenced by the timeoutID parameter. See setTimeout( ) for how to initiate such a delay.
Parameters

- An integer created as the return value of a setTimeout( ) method.

Returned Value
None.

close( ) | NN 2 IE 3 DOM n/a
Closes the current window. A script in a subwindow cannot close the main window without receiving the user's explicit permission from a security dialog box. A window can close itself (i.e., from a script running in the same window) or a window it generated via the window.open( ) method.
Parameters
None.
Returned Value
None.

confirm( ) | NN 2 IE 3 DOM n/a
confirm("message") |
Displays a dialog box with a message and two clickable buttons. Script execution halts while the dialog box appears. One button indicates a Cancel operation; the other button indicates the user's approval (OK or Yes). The text of the buttons is not scriptable. The message should ask a question to which either button would be a logical reply. A click of the Cancel button returns a value of false; a click of the OK button returns a value of true.
Because this method returns a Boolean value, you can use this method inside a condition expression:
    if (confirm("Reset the entire form?")) {
        document.forms[0].reset( );
    }
Parameters

- Any string, usually in the form of a question.

Returned Value
Boolean value: true | false.

createPopup( ) | NN n/a IE 5.5(Win) DOM n/a
Opens a blank popup rectangular space that can be populated with HTML content, yet the space can extend across frame boundaries and even window borders. Scripts must assign content (not an external URL) to the popup object returned by the method. See the popup object for more details and an example of usage.
Parameters
None.
Returned Value
popup object reference.

detachEvent( ) | NN n/a IE 5(Win) DOM n/a
detachEvent("eventName", functionReference) |
This IE event model method, shared among all element objects, is also a member of the window object. See the detachEvent( ) method discussion among the shared methods described earlier in this chapter.

disableExternalCapture( ), enableExternalCapture( ) | NN |4| IE n/a DOM n/a
With signed scripts and the user's permission, a script can capture events in other windows or frames that come from domains other than the one that served the document with event-capturing scripts. Navigator 4 only.
Parameters
None.
Returned Value
None.

dispatchEvent( ) | NN 6 IE n/a DOM 2
dispatchEvent(eventObjectReference) |
Although the window object is not officially part of the W3C DOM, Netscape 6 implements this W3C DOM event model method for the window object. See the dispatchEvent( ) method discussion among the shared methods described earlier in this chapter.

execScript( ) | NN n/a IE 4 DOM n/a
execScript(expressionList [, language]) |
Evaluates one or more script expressions in any scripting language embedded in the browser. Expressions must be contained within a single string; multiple expressions are delimited with semicolons:
    window.execScript("var x = 3; alert(x * 3)")
The default script language is JavaScript. If you need to see results of the script execution, provide for the display of resulting data in the script expressions, as shown in the example. The execScript( ) method itself returns no value.
Parameters

- String value of one or more semicolon-delimited script expressions.
- String value for a scripting language: JavaScript | JScript | VBS | VBScript.

Returned Value
None.

find( ) | NN 4 IE n/a DOM n/a
find("searchString"[, matchCase[, searchUpward]]) |
Searches the document body text for a string and selects the first matching string. Optionally, you can specify whether the search should be case-sensitive or should search upward in the document. With the found text selected in Navigator 4, you can then use the document.getSelection( ) method to grab a copy of the found text. You don't, however, have nearly the dynamic content abilities afforded by Internet Explorer 4's TextRange object (for Win32). This method is disconnected in Netscape 6 (it always returns false), but is reconnected in Netscape 7.
Parameters

- String for which to search the document.
- Boolean value: true to allow only exact, case-sensitive matches; false (default) to use case-insensitive search.
- Boolean value: true to search from the current selection position upward through the document; false (default) to search forward from the current selection position.

Returned Value
Boolean value: true if a match was found; false if not or Netscape 6 only.

focus( ) | NN 3 IE 4 DOM n/a
Brings the window to the front of all regular browser windows and fires the onFocus event (in IE). If another window had focus at the time, that other window receives an onBlur event.
Parameters
None.
Returned Value
None.

forward( ) | NN 4 IE n/a DOM n/a
Navigates one step forward through the history list of the window or frame. If the forward history has no entries, no action takes place.
Parameters
None.
Returned Value
None.

GetAttention( ) | NN |6| IE n/a DOM n/a
Mistakenly exposed to scripters, this method calls upon the operating system's way of alerting a user that the application needs attention. In Windows, the Taskbar box for the browser window flashes; in the Mac OS, a beep sounds, and a bullet appears next to the application in the Application menu. If the browser window is already at the front, no user signal appears. Removed for Netscape 7.
Parameters
None.
Returned Value
None.

getComputedStyle( ) | NN 6 IE n/a DOM 2
getComputedStyle(elementNodeReference, "pseudoElementName") |
Returns a style object (specifically, a CSSStyleDeclaration object in the W3C DOM terminology) showing the net cascade of style settings that affect the element passed as the first parameter. To retrieve a particular style attribute value (including a value inherited from the default browser style sheet), use the getPropertyValue( ) method of the style object returned from this method:
    var compStyle = getComputedStyle(document.getElementById("myP"), "");
    var pBGColor = compStyle.getPropertyValue("background-color");
See the style object for additional details.
Parameters

- Reference to an element node in the document tree that becomes the selection.
- String name of a pseudo-element (e.g., :first-line) or an empty string.

Returned Value
style (CSSStyleDeclaration) object reference.

getSelection( ) | NN 6 IE n/a DOM n/a
Returns a selection object, which can then be turned into a W3C DOM Range object. This method takes the place of the old document.getSelection( ) method, which is deprecated in Netscape 6. The corresponding IE operation is the document.selection property. See the selection object for details on working with a selection.
Parameters
None.
Returned Value
selection object reference.

home( ) | NN 4 IE n/a DOM n/a
Navigates to the URL designated as the home page for the browser. This is the same as the user clicking on the Home button.
Parameters
None.
Returned Value
None.

moveBy( ) | NN 4 IE 4 DOM n/a
moveBy(deltaX, deltaY) |
This is a convenience method that shifts the location of the window by specified pixel amounts along both axes. To shift along only one axis, set the other value to zero. Positive values for deltaX shift the window to the right; negative values to the left. Positive values for deltaY shift the window downward; negative values upward.
Parameters

- Positive or negative pixel count of the change in horizontal direction of the window.
- Positive or negative pixel count of the change in vertical direction of the window.

Returned Value
None.

moveTo( ) | NN 4 IE 4 DOM n/a
moveTo(x, y) |
This is a convenience method that shifts the location of the current window to a specific coordinate point. The moveTo( ) method uses the screen coordinate system.
Parameters

- Positive or negative pixel count relative to the top of the screen.
- Positive or negative pixel count relative to the left edge of the screen.

Returned Value
None.

navigate( ) | NN n/a IE 3 DOM n/a
navigate(URL) |
Loads a new document into the window or frame. This is the IE-specific way of assigning a value to the window.location.href property.
Parameters

- A complete or relative URL as a string.

Returned Value
None.

open( ) | NN 2 IE 3 DOM n/a
open("URL", "windowName"[, "windowFeatures"]) open("URL", "windowName"[, "windowFeatures"][, replaceFlag]) |
Opens a new window (without closing the original one). You can specify a URL to load into the new window or set that parameter to an empty string to allow scripts to document.write( ) into that new window. The windowName parameter lets you assign a name that can be used by target attributes of link and form elements. This name is not to be used in script references as frame names are. Instead, a script reference to a subwindow must be to the window object returned by the window.open( ) method. Therefore, if your scripts must communicate with a window opened in this manner, it is best to save the returned value as a global variable so that future statements can use it.
A potential problem with subwindows is that they can be buried under the main window if the user clicks on the main window (or a script gives it focus). Any script that opens a subwindow should also include a focus( ) method for the subwindow (in Navigator 3 and later, and in IE 4 and later) to make sure it comes to the front in case it is already open. Subsequent invocations of the window.open( ) method in which the windowName parameter is the same as an earlier call automatically address the previously opened window, even if it is underneath the main window (and thus without bringing the window to the front).
The optional third parameter gives you control over various physical attributes of the subwindow. The windowFeatures parameter is a single string consisting of a comma-delimited list (without spaces between items) of attribute/value pairs:
    newWindow = window.open("someDoc.html","subWind",
    "status,menubar,height=400,width=300");
    newWindow.focus( );
By default, all window attributes are turned on and the subwindow opens to the same size that the browser would use to open a new window from the File menu. But if your script specifies even one attribute, all settings are turned off. Therefore, use the windowFeatures parameter to specify those features that you want turned on.
If you encounter problems referencing a subwindow immediately after it is created, the problem is most likely a timing issue (affecting IE for Windows more than others). Script statements seem to want to reference the window before it exists completely. To work around the problem, place the code that works with the subwindow in a separate function, and invoke that function via the setTimeout( ) method, usually with no more than 50 milliseconds needed.
Managing multiple windows through scripts can be difficult. Security restrictions across domains frequently foil the best intentions. Users aren't always fond of windows appearing and hiding on their own. If your audience uses newer browsers, consider simulating windows with positioned elements.
Parameters

Attribute | NN | IE | Description
alwaysLowered | 4 | n/a | Always behind all other browser windows. Signed script required.
alwaysRaised | 4 | n/a | Always in front of all other browser windows. Signed script required.
channelMode | n/a | 4 | Show in theater mode with channel band.
copyhistory | 2 | 3 | Copy history listing from opening window to new window.
dependent | 4 | n/a | Subwindow closes if the window that opened it closes.
directories | 2 | 3 | Display directory buttons.
fullscreen | n/a | 4 | Display no titlebar or menus
height | 2 | 3 | Window height in pixels.
hotkeys | 4 | n/a | Disables menu keyboard shortcuts (except Quit and Security Info).
innerHeight | 4 | n/a | Content region height. Signed script required for very small measures.
innerWidth | 4 | n/a | Content region width. Signed script required for very small measures.
left | 6 | 4 | Offset of window's left edge from left edge of screen.
location | 2 | 3 | Display Location (or Address) text field.
menubar | 2 | 3 | Display menubar (a menubar is always visible on Mac).
outerHeight | 4 | n/a | Total window height. Signed script required for very small measures.
outerWidth | 4 | n/a | Total window width. Signed script required for very small measures.
resizable | 2 | 3 | Allow window resizing (always allowed on Mac).
screenX | 4 | n/a | Offset of window's left edge from left edge of screen. Signed script required to move window offscreen.
screenY | 4 | n/a | Offset of window's top edge from top edge of screen. Signed script required to move window offscreen.
scrollbars | 2 | 3 | Display scrollbars if document is too large for window.
status | 2 | 3 | Display status bar.
titlebar | 4 | n/a | Displays titlebar. Set this value to no to hide the titlebar. Signed script required.
toolbar | 2 | 3 | Display toolbar (with Back, Forward, and other buttons).
top | 6 | 4 | Offset of window's top edge from top edge of screen.
width | 2 | 3 | Window width in pixels.
z-lock | 4 | n/a | New window is fixed below browser windows. Signed script required.

- A complete or relative URL as a string. If an empty string, no document loads into the window.
- An identifier for the window to be used by target attributes. This is different from the title attribute of the document that loads into the window.
- A string of comma-delimited features to be turned on in the new window. Do not put spaces after the comma delimiters. The list of possible features is long, but a number of them are specific to Navigator 4 or later and require signed scripts because they are potentially a privacy and security concern to unsuspecting users. The features are listed as follows. To turn on a window feature, simply include its case-insensitive name in the comma-separated list. Only attributes specifying dimensions require values be assigned.

- Boolean value (for IE only) that controls the effect of the new window's URL on the global history of the browser. Set to true to replace the current page with the new window's URL (so that the current page won't be accessed through the Back button); set to false to add the new window's URL to the history, as normal.

Returned Value
Window object reference.

print( ) | NN 4 IE 5 DOM n/a
Starts the printing process for the window or frame. A user must still confirm the print dialog box to send the document to the printer. This method is the same as clicking the browser's Print button or selecting Print from the File menu.
Parameters
None.
Returned Value
None.

prompt( ) | NN 2 IE 3 DOM n/a
prompt("message", "defaultReply") |
Displays a dialog box with a message, a one-line text entry field, and two clickable buttons. Script execution halts while the dialog box appears. The message should urge the user to enter a specific kind of answer. One button indicates a Cancel operation; the other button indicates the user's approval of the text entered into the field (OK or Yes). The text of the buttons is not scriptable. A click of the Cancel button returns a value of null; a click of the OK button returns a string of whatever is in the text entry field at the time (including the possibility of an empty string). It is up to your scripts to test for the type of response (if any) supplied by the user.
Parameters

- Any string.
- Any string that suggests an answer. Always supply a value, even if an empty string.

Returned Value
When clicking the OK button, a string of the text entry field; when clicking Cancel, null.

releaseEvents( ) | NN 4 IE n/a DOM n/a
releaseEvents(eventTypeList) |
The opposite of window.captureEvents( ), this method turns off event capture at the window level for one or more specific events named in the parameter list. Although this method is part of the Navigator 4 event model, it continues to be supported in Netscape 6, creating the equivalent of a W3C DOM capture-mode event listener for the document object. Continue to use this method if you must support Navigator 4, but migrate new code to the W3C DOM event listener syntax as described in Chapter 6.
Parameters

eventTypeList

  A comma-separated list of case-sensitive event types as derived from the available Event object constants, such as Event.CLICK or Event.MOUSEMOVE.

Returned Value
None.

removeEventListener( ) | NN 6 IE n/a DOM n/a
removeEventListener("eventType", listenerFunction, useCapture) |
Although the window object as we know it is not officially part of the W3C DOM, Netscape 6 implements this W3C DOM event model method for the window object. See the removeEventListener( ) method discussion among the shared methods described earlier in this chapter.

resizeBy( ) | NN 4 IE 4 DOM n/a
resizeBy(deltaX, deltaY) |
This is a convenience method that shifts the width and height of the window by specified pixel amounts. To adjust along only one axis, set the other value to zero. Positive values for deltaX make the window wider; negative values make the window narrower. Positive values for deltaY make the window taller; negative values make the window shorter. The top and left edges remain fixed; only the right and bottom edges are moved.
Parameters

- Positive or negative pixel count of the change in horizontal dimension of the window.
- Positive or negative pixel count of the change in vertical dimension of the window.

Returned Value
None.

resizeTo( ) | NN 4 IE 4 DOM n/a
resizeTo(x, y) |
This is a convenience method that adjusts the height and width of the window to specific pixel sizes. The top and left edges of the window remain fixed, while the bottom and right edges move in response to this method.
Parameters

- Width in pixels of the window.
- Height in pixels of the window.

Returned Value
None.

routeEvent( ) | NN |4| IE n/a DOM n/a
routeEvent(event) |
Used inside an event handler function, this method directs Navigator 4 (only) to let the event pass to its intended target object.
Parameters

- A Navigator 4 event object.

Returned Value
None.

scroll( ) | NN 3 IE 4 DOM n/a
scroll(x, y) |
Sets the scrolled position of the document inside the current window or frame. To return the document to its unscrolled position, set both parameters to zero.
Parameters

- Horizontal measure of scrolling within the window.
- Vertical measure of scrolling within the window.

Returned Value
None.

scrollBy( ) | NN 4 IE 4 DOM n/a
scrollBy(deltaX, deltaY) |
Scrolls the document in the window by specified pixel amounts along both axes. To adjust along only one axis, set the other value to zero. Positive values for deltaX scroll the document to the left (so the user sees content to the right in the document); negative values scroll the document to the right. Positive values for deltaY scroll the document upward (so the user sees content lower in the document); negative values scroll the document downward. Scrolling does not continue past the zero coordinate points (except in Navigator 4 for the Macintosh).
Parameters

- Positive or negative pixel count of the change in horizontal scroll position.
- Positive or negative pixel count of the change in vertical scroll position.

Returned Value
None.

scrollByLines( ), scrollByPages( ) | NN 6 IE n/a DOM n/a
scrollByLines(intervalCount) scrollByPages(intervalCount) |
Scroll the document in the window downward (positive value) or upward (negative value) by the increment of lines or pages. The methods perform the same actions as the user clicking on the arrow and "page" regions of the vertical scrollbar, respectively.
Parameters

- Positive or negative count of the change in vertical scroll position. Units are governed by the method choice (lines or pages).

Returned Value
None.

scrollTo( ) | NN 4 IE 4 DOM n/a
scrollTo(x, y) |
Scrolls the document in the window to a specific scrolled pixel position.
Parameters

- Horizontal position in pixels of the window.
- Vertical position in pixels of the window.

Returned Value
None.

setCursor( ) | NN |6| IE n/a DOM n/a
setCursor("cursorType") |
Changes the cursor to a desired type. This method is an alternate to the style sheet cursor attribute. Starting with Netscape 6.2, a cursor changed with this method maintains its shape until explicitly changed to another shape or the default auto style. Precise cursor shape is determined by the operating system repertoire. Removed from Netscape 7.
Parameters

alias | auto | cell | context-menu
copy | count-down | count-up | count-up-down
crosshair | default | e-resize | grab
grabbing | help | move | n-resize
ne-resize | nw-resize | pointer | s-resize
se-resize | spinning | sw-resize | text
w-resize | wait |  |

- String name of a cursor style such as:

Returned Value
None.

setInterval( ) | NN 4 IE 4 DOM n/a
setInterval("scriptExpression", msecs[, language]) setInterval(functionReference, msecs[, arg1, ..., argN]) |
Starts a timer that continually invokes the expression every msecs. Other scripts can run in the time between calls to expression. This method is useful for starting animation sequences that must reposition an element along a path at a fixed rate of speed. A repetitive call to an animation function would look like the following:
    intervalID = setInterval("advanceAnimation( )", 500);
The parameter situation can be confusing. The simplest, most cross-browser approach is to invoke a script function (as a string), with the interval time (in milliseconds) as the second parameter. Any script expression will execute, but the expression is evaluated at the time the setInterval( ) method is invoked. Therefore, if you concatenate variables into this expression, their values must be ready when the setInterval( ) method runs, even though the variables won't be used until some milliseconds later.
IE permits a third parameter to specify a different scripting language in which the expression is to run. Unless it is a VBScript expression, you can omit this parameter. Navigator, however, lets you substitute a function reference (not a string) as the first parameter, and pass a comma-delimited list of parameters that go to the function call. These parameters go after the msecs time, and they can be any data types.
This method returns an ID that should be saved as a global variable and be available as the parameter for the clearInterval( ) method to stop the looping timer. Unless you explicitly clear the interval process, it will continue to execute until the page unloads.
Parameters

- Any script expression as a string, but most commonly a function. The function name with parentheses is placed inside the parameter's quoted string.
- Nonstring function reference (function name without the parentheses).
- The time in milliseconds between invocations of the expression or functionReference.
- An optional comma-delimited list of parameters to be passed to a function used as the functionReference parameter. Navigator only.
- An optional scripting language specification of the expression parameter (default is JavaScript). IE for Windows only.

Returned Value
Integer acting as an identifier for this repetitive process.

setTimeout( ) | NN 2 IE 3 DOM n/a
setTimeout("scriptExpression", msecs[, language]) setTimeout(functionReference, msecs[, arg1, ..., argN]) |
Starts a one-time timer that invokes the scriptExpression or functionReference after a delay of msecs. Other scripts can run while the browser waits to invoke the expression. A statement that sets the timer would look like the following:
    timeoutID = setTimeout("finishWindow( )", 50);
The parameter situation can be confusing. The simplest, most cross-browser approach is to invoke a script function (as a string), with the interval time (in milliseconds) as the second parameter. Any script expression will execute, but the expression is evaluated at the time the setTimeout( ) method is invoked. Therefore, if you concatenate variables into this expression, their values must be ready when the setTimeout( ) method runs, even though the variables won't be used until some milliseconds later.
IE permits a third parameter to specify a different scripting language in which the expression is to run. Unless it is a VBScript expression, you can omit this parameter. Navigator, however, lets you substitute a function reference (not a string) as the first parameter, and pass a comma-delimited list of parameters that go to the function call. These parameters go after the msecs time, and they can be any data types.
This method returns an ID that should be saved as a global variable and be available as the parameter for the clearTimeout( ) method to stop the timer before it expires and invokes the delayed action.
The setTimeout( ) method can be made to behave like the setInterval( ) method in some constructions. If you place a setTimeout( ) method as the last statement of a function and direct the method to invoke the very same function, you can create looping execution with a timed delay between executions. This is how earlier browsers (before the setInterval( ) method was available) scripted repetitive tasks, such as displaying updated digital clock displays in form fields or the status bar.
Parameters

scriptExpression

  Any script expression as a string, but most commonly a function. The function name with parentheses is placed inside the parameter's quoted string.

functionReference

  Nonstring function reference (function name without the parentheses).

msecs

  The time in milliseconds between invocations of the expression or functionReference.

args

  An optional comma-delimited list of parameters to be passed to a function used as the functionReference parameter. Navigator only.

language

  An optional scripting language specification of the expression parameter (default is JavaScript). IE for Windows only.

Returned Value
Integer acting as an identifier.

showHelp( ) | NN n/a IE 4(Win) DOM n/a
showHelp("URL") |
Displays a WinHelp window with the .hlp document specified with the URL parameter.
Parameters

- A complete or relative URL to a WinHelp formatted file as a string.

Returned Value
None.

showModalDialog( ) | NN n/a IE 4 DOM n/a
showModalDialog("URL"[, arguments[, "features"]]) |
Displays a special window that remains atop all browser windows until the user explicitly closes the dialog window. This kind of window is different from the browser windows generated with the window.open( ) method. A modal dialog has no scriptable relationship with its opening window once the dialog window is opened. All values necessary for displaying content must be in the HTML document that loads into the window or be passed as parameters. The modal dialog may then have a script set its returnValue property, which becomes the value returned to the original script statement that opened the modal dialog box as the returned value of the showModalDialog( ) method.
You can pass arguments to the modal dialog by creating a data structure that best suits the data. For a single value, a string will do. For multiple values, you can create a string with a unique delimiter between values, or create an array and specify the array as the second parameter for the showModalDialog( ) method. A script in the document loaded into the modal dialog can then examine the window.dialogArguments property and parse the arguments as needed for its scripting purposes. See the dialogArguments property for an example.
The third optional parameter lets you set physical characteristics of the dialog window. These characteristics are specified in a CSS-style syntax. Dimensions for dialogWidth, dialogHeight, dialogLeft, and dialogTop should be specified in pixels. An example of a call to a modal dialog is as follows:
    var answer = window.showModalDialog("subDoc.html",argsVariable,
    "dialogWidth:300px; dialogHeight:200px; center:yes");
None of the third parameter characteristics are recognized by the Macintosh version of Internet Explorer 4, which creates a full-size modal dialog.
Modal dialogs can present problems for scripts if the window loads a frameset. A script in one of the frames will likely not be able to reference the parent or top window to gain access to either the window's close( ) method or content in another frame.
Parameters

Feature | Value | Description
center | yes | no | 1 | 0 | on | off | Center the dialog
dialogHeight | Length/units | Outer height of dialog
dialogLeft | Integer | Left pixel offset (overrides center)
dialogTop | Integer | Top pixel offset (overrides center)
dialogWidth | Length/units | Outer width of dialog
edge | raised | sunken | Transition style between border and content area
help | yes | no | 1 | 0 | on | off | Display help icon in titlebar
resizable | yes | no | 1 | 0 | on | off | Dialog is resizable
status | yes | no | 1 | 0 | on | off | Display status bar

- A complete or relative URL as a string.
- Data as a number, string, or array to be passed to the scripts in the document loaded into the modal dialog.
- A string of semicolon-delimited style attributes and values to set the physical characteristics of the modal dialog. Available attributes are as shown in the following table.

Returned Value
The value (if any) assigned to the window.returnValue property in the document loaded into the modal dialog window.

showModelessDialog( ) | NN n/a IE 5(Win) DOM n/a
showModelessDialog("URL"[, arguments[, "features"]]) |
Displays a special window that remains atop all browser windows, yet allows the user to interact with other open windows and their content. Other than browser versions that support it, this method has the same parameters and characteristics as the showModalDialog( ) method. See that method for details.

sizeToContent( ) | NN 6 IE n/a DOM n/a
Lets the browser determine the optimum window size to display the window's content. Suitable for subwindows that display a limited amount of information.
Parameters
None.
Returned Value
None.

stop( ) | NN 4 IE n/a DOM n/a
Halts the download of external data of any kind. This method is the same as clicking the browser's Stop button.
Parameters
None.
Returned Value
None.

handleEvent[ ] | NN |4| IE n/a DOM n/a
handleEvent(event) |
Instructs the object to accept and process the event whose specifications are passed as the parameter to the method. The object must have an event handler for the event type to process the event. Navigator 4 only.
Parameters

- A Navigator 4 event object.

Returned Value
None.