Chapter 6. BOM


JavaScript has an intermediate layer between Core (discussed in the previous chapter) and the Document Object Model, or DOM (to be discussed in Chapters 7-10). Commonly called the Browser Object Model, or BOM, this layer is specific to JavaScript's client-side implementation, so it's not part of Core. It does not work with the HTML document, so it's not part of the DOM, either. The BOM's most important task is managing browser windows (each of which have a separate window object) and enabling communication between them. Therefore, the window object stands at the center of the BOM.

Nonetheless, as you'll notice, BOM is also the catch-all category of JavaScript. There are many objects, methods, and properties that are not part of the document structure (for instance, the URL of the current page or the identification string of the browser), and these are defined on the window object.

Standards-wise, BOM is a bit of a problem. Core has been standardized by ECMA, and most aspects of the DOM have been specified by W3C. In contrast, the BOM has not yet officially been defined by any standards organization, although at the time of writing, WHAT-WG is working on a specification. Fortunately, the most important BOM features were all part of the de facto Netscape 3 standard, and are therefore supported by all browsers.

Site Survey is the quintessential BOM script. It's useful to compare it to the other example scripts, to highlight the difference between DOM and BOM.

All the other example scripts change an HTML document; for instance, by moving HTML elements through the document (Sandwich Picker, Usable Forms), changing the styles of elements (Edit Style Sheet, Dropdown Menu, XMLHTTP Speed Meter), or checking user input in a form field (Form Validation, Textarea Maxlength).

In contrast, Site Survey hardly changes anything in the document. The script sits quietly in its corner (a popup) and registers what users are doing in the site by storing the URLs of all pages they visit. Ideally, the user never notices it's there, until the script opens the survey page and politely requests the user to participate.

What-WG

The Web Hypertext Application Technology Working Group (WHAT-WG) is an unofficial collaboration of browser vendors and other interested parties who work on the development of new, advanced technologies for delivering applications on the Web. Although WHAT-WG's specifications have no official status, some WHAT-WG members are also W3C members, while others are well-known Web developers; all of them support WHAT-WG's recommendations in word and deed. It is likely that WHAT-WG's ideas will eventually find their way into the official W3C specs and new browser versions.

WHAT-WG's best-known specification is Web Forms 2.0, in which the group defines new form widgets such as sliders and date/time fields, and proposes ways of adding these widgets to HTML.

Developers who are interested in innovating technologies that will make Web sites easier to useand possible JavaScript implementations of these technologiesshould take the time to acquaint themselves with the WHAT-WG's projects. Their Web site can be found at http://whatwg.org/.


The core tasks of Site Survey are to remember whether users are selected for the survey and to ensure that the popup stays in contact with the main window, even when the user requests new pages. Thus, Site Survey mainly concerns itself with window-related information such as the URL of the current page or cookies associated with it. It does not work with DOM information such as the existence and value of form fields. The window object is more important to Site Survey than the document object.



ppk on JavaScript. Modern, Accessible, Unobtrusive JavaScript Explained by Means of Eight Real-World Example Scripts2006
ppk on JavaScript. Modern, Accessible, Unobtrusive JavaScript Explained by Means of Eight Real-World Example Scripts2006
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 116

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net