Main Page

Why the DOM is necessary

By creating a tree to represent a document, the DOM allows developers an unprecedented level of con-
trol over its content and structure. Nodes can easily be removed, added, and replaced by using the
Why the DOM is necessary
With Internet Explorer 4.0 and Netscape Navigator 4.0 each supporting different forms of Dynamic
HTML (DHTML), developers for the first time could alter the appearance and content of a Web page
without reloading it. This represented a tremendous step forward in Web technology, but also a huge
problem. Netscape and Microsoft each went its own way in developing DHTML, thus ending the period
when Web developers could write a single HTML page that could be accessed by any Web browser.
It was decided that something had to be done to preserve the cross-platform nature of the Web. The fear
was that, if someone didn’t rein in Netscape and Microsoft, the Web would develop into two distinct fac-
tions that were exclusive to targeted browsers. It was then that the World Wide Web Consortium (W3C),
the body charged with creating standards for Web communication, began working on the DOM.
DOM levels
DOM Level 1 became a W3C recommendation in October of 1998. It consisted of two modules: the DOM
Core, which provided a way to map the structure of an XML-based document to allow for easy access to
and manipulation of any part of a document, and the DOM HTML, which extended the DOM Core by
adding HTML-specific objects and methods.
Note that the DOM is not JavaScript-specific, and indeed has been implemented in numerous other lan-
guages. For Web browsers, however, the DOM has been implemented using ECMAScript and now
makes up a large part of the JavaScript language.
Whereas DOM Level 1’s only goal was to map out the structure of a document, DOM Level 2’s aims
were much broader. This extension to the original DOM added support for mouse and user interface
events (long supported by DHTML), ranges, traversals (methods to iterate over a DOM document), and
support for Cascading Style Sheets (CSS) through object interfaces. The original DOM Core introduced
in Level 1 was also extended to include support for XML namespaces.
DOM Level 2 introduced several new modules of the DOM to deal with new types of interfaces:
DOM Views — describes interfaces to keep track of the various views of a document (that is,
the document before CSS styling and the document after CSS styling)
DOM Events — describes interfaces for events
DOM Style — describes interfaces to deal with CSS-based styles
DOM Traversal and Range — describes interfaces to traverse and manipulate a document tree
DOM Level 3 further extends the DOM with the introduction of methods to load and save documents in
a uniform way (contained in a new module called DOM Load and Save) as well as methods to validate a
document (DOM Validation). In Level 3, the DOM Core is extended to support all of XML 1.0, including
XML Infoset, XPath, and XML Base.
What Is JavaScript?
04_579088 ch01.qxd 3/28/05 11:34 AM Page 7

JavaScript EditorFree JavaScript Editor     Ajax Editor