Main Page

Browser Object Model

The Browser Object Model
You can’t really talk about JavaScript in the browser without talking about the Browser Object Model
(BOM), which provides objects that interact with the browser window independent of the content.
The BOM is made up of a series of objects that are related to one another. Figure 5-3 shows the basic
BOM hierarchy.
Figure 5-3
As you can see, the
window
object is the center of the BOM universe, with all objects and collections
somehow connecting back to it. I begin the discussion of the BOM with this object.
The window object
The
window
object represents an entire browser window, but not necessarily the content that the win-
dow contains. Rather,
window
can be used to move, resize, and otherwise affect the browser that it
represents.
If a page uses framesets, each frame is represented by its own
window
object and stored in the
frames
collection. Within the
frames
collection, the window objects are indexed both by number (starting at
0, going first left-to-right, then row-by-row) and by the name of the frame. Consider the following
example:
<html>
<head>
<title>Frameset Example</title>
window
document
location
histor y
location
navigator
screen
Array
frames
anchors
forms
images
links
Object
KEY
136
Chapter 5
08_579088 ch05.qxd 3/28/05 11:37 AM Page 136


JavaScript EditorFree JavaScript Editor     Ajax Editor


©