1. Technology

The Browser Object Model

1. Introduction


JavaScript consists of three parts. Two of these parts (the core component and Document Object Model) both have defined standards that all browsers are supposed to follow. The third part is the Browser Object Model and there is no official standard for this part of JavaScript. Fortunately for us even though there is no actual standard for this part of JavaScript most browsers have implemented the same commands to do the same (or almost the same) things and for those few areas where a browser does implement something in a different way we can use feature sensing to test which one is supported by the current browser.

So what exactly is the Browser Object Model? The Browser Object Model (or BOM for short) is that part of JavaScript that allows JavaScript to interface and interact with the browser itself. As JavaScript can also run in environments other than web browsers these are also the parts of JavaScript that may be unsupported or completely different when JavaScript is run somewhere other than a web browser. For the most part though, at least in web browsers, it is to the benefit of the browser writers themselves to implement the same processes in the same way as other web browsers so that existing code written for other browsers will also work in theirs.

A lot of the BOM calls date back to the earliest days of JavaScript and have been available for JavaScript to use since it was first introduced in Netscape 2. If anything there are fewer BOM commands that are usable now than there were back at the start since there have been a number of them that have been disabled as browsers have introduced measures to protect people's security since certain of the commands made scamming the people visiting a web site much easier or have been overused to really annoy people.

Another thing that we need to consider regarding the commands that make up the BOM portion of JavaScript is that a lot of them rely on information that is available to the browser. In some instances the information that the browser has may be wrong (eg. browsers do not know about operating systems introduced after the browser was released) or may be able to be changed by the person who owns the browser.

One final point to consider regarding the BOM commands is that you need to consider exactly what the particular value you are accessing means and its relevance to what you are trying to do. These commands are amongst the most misused commands in the JavaScript language (for example testing the screen width and then using that to determine how wide to make something in the browser window where the browser window size is completely independent of the screen width).

The usefulness of the BOM commands varies from commands that are extremely useful to those that serve no useful purpose whatever.

More of this Tutorial

Related Video
Screen Capture With the Snip Tool in Windows Vista
  1. About.com
  2. Technology
  3. JavaScript

©2014 About.com. All rights reserved.