We begin this chapter with an overview of some of the most
commonly used properties and methods of the Window object. Later sections of
the chapter explain this material in more detail. As usual, the client-side
reference section contains complete coverage of Window object properties and
methods.

The most important properties of the Window object are the
following:

closed

A boolean value that is true only if the window has been closed.

defaultStatus, status

The text that appears in
the status line of the browser.

document

A reference to the Document object that represents
the HTML document displayed in the window. The Document object is covered in
detail in Chapter 14.

frames[]

An array of Window objects that represent the frames
(if any) within the window.

history

A reference to the History object that represents the
user's browsing history for the window.

location

A reference to the Location object that represents
the URL of the document displayed in the window. Setting this property
causes the browser to load a new document.

name

The name of the window. Can be used with the target attribute of the HTML <a> tag, for example.

opener

A reference to the Window object that opened this
one, or null if this window was opened by the
user.

parent

If the current window is a frame, a reference to the
frame of the window that contains it.

self

A self-referential property; a reference to the
current Window object. A synonym for window.

top

If the current window is a frame, a reference to the
Window object of the top-level window that contains the frame. Note that
top is different from parent for frames nested within other frames.

window

A self-referential property; a reference to the
current Window object. A synonym for self.

The Window object also supports a number of important
methods:

alert( ), confirm( ), prompt( )

Display simple dialog boxes to the user and, for
confirm( ) and prompt(
), get the user's response.

close( )

Close the window.

focus( ), blur( )

Request or relinquish keyboard focus for the window.
The focus( ) method also ensures that the window
is visible by bringing it to the front of the stacking order.

moveBy( ), moveTo( )

Move the window.

open( )

Open a new top-level window to display a specified
URL with a specified set of features.

print( )

Print the window or frame--same as if the user had
selected the Print button from the window's
toolbar (Netscape 4 and later and IE 5 and later only).

resizeBy( ), resizeTo( )

Resize the window.

scrollBy( ), scrollTo( )

Scroll the document displayed within the window.

setInterval( ), clearInterval( )

Schedule or cancel a function to be repeatedly
invoked with a specified delay between invocations.

setTimeout( ), clearTimeout( )

Schedule or cancel a function to be invoked once
after a specified number of milliseconds.

As you can see from these lists, the Window object provides
quite a bit of functionality. The remainder of this chapter explores much of
that functionality in more detail.