-
Book Overview & Buying
-
Table Of Contents
Object-Oriented JavaScript
The BOM (Browser Object Model) is a collection of objects that give you access to the browser and the computer screen. These objects are accessible through the global objects window and window.screen.
As you know already, in JavaScript there's a global object provided by every host environment. In the browser environment, this is the window object. All global variables become properties of the window object.
>>> window.somevar = 1;
1
>>> somevar
1
Also, all of the core JavaScript functions (discussed in Chapter 2) are methods of the window object.
>>> parseInt('123a456')123
>>> window.parseInt('123a456')123
In addition to being the global object, the window object also serves a second purpose and that is to provide data about the browser environment. There's a window object for every frame, iframe, popup, or browser tab.
Let's see some of the browser-related properties of the window object. Again...
Change the font size
Change margin width
Change background colour