The Web Professional's Handbook: Document Object Models -WebReference.com- | WebReference

The Web Professional's Handbook: Document Object Models -WebReference.com-

The Web Professional's Handbook: Document Object Models

DOM History

To understand why the DOMs are as they are and why there are four, it's best to start with a bit of browser history.

The Level 0 DOM

It was Netscape that invented JavaScript and incorporated it in the Netscape 2 browser. Right from the start, it was necessary to have some access to HTML elements, so Netscape was careful to add a DOM to its browser. Today, this DOM is known as the Level 0 DOM. It offers only very limited access to the HTML page: in Netscape 2 it was only possible to access form elements and hyperlinks. In Netscape 3, images were added to the list, making possible the famous rollover effect (of which we'll see an example later).

Competitors arrived. Microsoft, especially, was eager to promote its own IE as a viable alternative to Netscape. They were careful to copy the Level 0 DOM, and to make sure IE reacted to scripts in the same way as Netscape did. Unfortunately, IE 3 couldn't access images where Netscape 3 could, creating the first of the cross-browser compatibility problems.

Later, when other browsers like Opera came into play, they too carefully copied Netscape's Level 0 DOM. Even the version 5 or higher browsers still support it, since there are millions of web pages using the Level 0 DOM and any JavaScript browser must be able to execute these scripts. It has never been standardized by W3C, however. Instead, Netscape 3 remains the touchstone of Level 0 DOM-compatibility. Any newer JavaScript HTML browser should support everything that Netscape 3 supports .

If you use the Level 0 DOM you can be almost certain that your scripts will work in all JavaScript browsers. For optimal browser-compatibility of HTML pages, it's best to use the Level 0 DOM where possible.

The Intermediate DOMs

Both Netscape 4 and IE 4 supported DHTML: the changing of element styles (like their position, their background color) and content through JavaScript. In order to make DHTML possible, the DOM of the browsers had to be upgraded. It now had to provide access not only to forms, links, and images, but also to other HTML elements.

Netscape assumed that, as before, other browsers would follow its lead. However, since Microsoft challenged Netscape's dominance on the browser market, it chose to develop its own DOM and to ignore that which the Netscape programmers were creating. This resulted in the two browsers each supporting its own DOM, these DOMs being completely incompatible. Thus came the era of the Browser Wars. While Netscape and Microsoft fought for dominance of the browser market, web developers were forced to write complicated cross-browser scripts and to work around the sometimes considerable differences between the two browsers.

In hindsight, the Microsoft DOM was seen as better, and is far closer to the eventual W3C DOM standards, than Netscape's. For this reason and others, IE continued to make inroads into the Netscape market share.

Created: February 18, 2003
Revised: February 18, 2003

URL: http://webreference.com/programming/professional/chap6/1