HTML and CSS Reference
In-Depth Information
10.1.2 Working with the window Object
The window object is where all the action happens in a browser. It's at the top of the Java-
Script hierarchy, and is automatically defined for each window that you open, as repre-
sented in Figure 10.12. When you start up your browser, you may stay in the current
window until you exit the browser, or you may have any number of windows open at
the same time. Within each window you browse the Internet, read e-mail, search for
cheap airline tickets, and buy a new book. Each new page you bring up is a document
within the current window. The window is often partitioned into independent display
areas, called frames, which are windows within windows. (Frames are discussed in the
section “Working with Frames” on page 303.)
The window object comes with a number of properties and methods. Because it is the
basis of all objects, the name of the window object can be excluded when applying meth-
ods to it; for example, it is not necessary to specify window.alert(“Watch out!”) or win-
dow.document.write(“OK”) . You simply use alert(“Watch out!”) or document.write(“OK”) .
When a user clicks a button or rolls the mouse over a link, an event occurs that often
affects the behavior of a window. Such user-initiated events are discussed in Chapter 13,
“Handling Events.”
Object's Properties and Methods. The window object has a number of properties,
which are also objects in their own right. Table 10.4 lists those properties and how they
describe the attributes of the window.
Table 10.4 Properties of the window Object
Property
What It Describes
closed
True if the window is closed.
defaultStatus
The default status message displayed in the status bar at the bottom
of the window.
document
The document object that is currently displayed in the window.
frames
An array of frame objects within the window.
history
The history object containing the URLs last loaded into the
window.
length
The number of frames within the window.
location
The URL of the current window.
name
The name of the window.
offscreenBuffering
Used to draw new window content and then copy it over existing
content when complete; controls screen updates.
Continues
 
 
Search WWH ::




Custom Search