Java Reference
In-Depth Information
The Browser Object Model
The Browser Object Model (or BOM for short) is a collection of properties and methods that
contain information about the browser and computer screen. For example, we can find out
which browser the users are utilising (though, this method is unreliable), the dimensions of
their screens, and which pages they have visited before the current page. It can also be used
for the rather dubious practice of creating pop-up windows, if you're into annoying your
users.
There is no official standard for the BOM, although there are a number of properties
and methods that are supported by all the major browsers, making a sort of de facto
standard. These properties and methods are made available through the window object.
Every browser window, tab, popup, frame, and iframe has a window object.
Note: There Isn't Always a BOM
Remember that JavaScript can be run in different environments. The BOM
only makes sense in a browser environment. This means that other environ-
ments (such as Node.js) may not have a window object, although they will
still have a global object; for example, Node.js has an object called global .
Going Global
All the way back in Chapter 2, we introduced the concept of global variables. These are vari-
ables that are created without using the var keyword. Global variables can be accessed in
all parts of the program.
Global variables are actual properties of a global object. In a browser environment, the glob-
al object is the window object. This means that any global variable created is actually a
property of the window object:
x = 6;
<< 6
window.x;
<< 6
 
Search WWH ::




Custom Search