BOM and DOM - an overview

The JavaScript code in a page has access to a number of objects. These objects can be divided into the following types:

  • Core ECMAScript objects: This consists of all the objects mentioned in the previous chapters
  • DOM: This consists of objects that have to do with the currently loaded page, which is also called the document
  • BOM: This consists of objects that deal with everything outside the page-the browser window and the desktop screen

DOM stands for Document Object Model and BOM for Browser Object Model.

The DOM is a standard governed by the World Wide Web Consortium (W3C) and has different versions, called levels, such as DOM Level 1, DOM Level 2, and so on. Browsers in use today have different degrees of compliance with the standard, but in general, they almost all completely implement DOM Level 1. The DOM was standardized post factum after the browser vendors had each implemented their own ways to access the document. The legacy part from before the W3C took over is still around and is referred to as DOM 0, although, no real DOM Level 0 standard exists. Some parts of DOM 0 have become de facto standards as all major browsers support them; some of these were added to the DOM Level 1 standard. The rest of DOM 0 that didn't find its way to DOM 1 is too browser specific and won't be discussed here.

Historically, BOM was not a part of any standard. Similar to DOM 0, it has a subset of objects that is supported by all major browsers, and another subset that is browser-specific. The HTML5 standard codifies common behavior among browsers, and it includes common BOM objects. Additionally, mobile devices come with their specific objects (and HTML5 aims to standardize those as well), which traditionally were not necessary for desktop computers, but make sense in a mobile world, for example, geolocation, camera access, vibration, touch events, telephony, and SMS.

This chapter discusses only cross-browser subsets of BOM and DOM Level 1, unless noted otherwise in the text. Even these safe subsets constitute a large topic, and a full reference is beyond the scope of this book. You can also consult the following references:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.37.35