Chapter 9. Browser As Puzzle Box

The Browser Object Model (BOM) is a set of objects inherited from the browser context in which most JavaScript applications function. Sometimes referred to as the Document Object Model (DOM) Level 0, or even as the DOM, the BOM is a finite set of common web objects that have been accessible via JavaScript since earlier versions of Netscape Navigator and Microsoft’s Internet Explorer.

Previous chapters demonstrated some of the objects, such as window, document, and form. This chapter looks at these objects more closely, as well as the other objects that complete the BOM.

The Structure of the Browser at a Glance

The BOM forms a hierarchy of objects, with objects at each level accessible via parent objects above them. You can access all of the elements of the BOM via window, which is the topmost element. The next level below features document, the object used most often in previous examples. The level also contains the navigator, frames, location, history, and screen objects. From the document, several collections of objects are accessible: forms, anchors, links, cookies, and images. As I demonstrated in Chapter 8, the form object also has collections of elements as children.

Figure 9-1 shows the BOM at a glance, and how all of these elements relate to each other.

Hierarchy of the BOM

Figure 9-1. Hierarchy of the BOM

An object property can be a single object that may or may not ...

Get Learning JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.