HTML and CSS Reference
In-Depth Information
chapter
10
It's the BOM!
Browser Objects
10.1 JavaScript and the Browser Object Model
JavaScript programs are associated with a browser window and the document displayed
in the window. The window is a browser object and the document is an HTML object.
In the browser object model, sometimes called BOM, the window is at the top of the tree,
and below it are objects: window , navigator , frames[] , document , history , location , and
screen . See Figure 10.1.
Current
Window
self,
window,
parent, top
Window
objects
navigator
Navigator
object
frames[]
Array of
Window
objects
document
Document
object
history
History
object
location
Location
object
screen
Screen
object
Figure 10.1 The hierarchy of the browser object model.
If you are writing a JavaScript program that needs to manipulate the window, then you
would use the window object and properties and methods associated with it. For example,
the status property of the window object is used when you want to display text in the sta-
tus bar, and the window's alert method allows you to send a message to a dialog box.
The document object model refers to the HTML document and all the elements and attri-
butes associated with it. Because your Web page is so closely linked to HTML (or XML),
JavaScript uses the DOM to access the HTML elements and attributes within a page. The
document is the root of this model. Each HTML element is assigned to an object: There are
271
 
 
 
Search WWH ::




Custom Search