The document object is the foundation around which a scriptable interface to an HTML or XML document is constructed. This is sometimes referred to as the DOM and is subject to its own standardization exercise being managed by W3C and other interested parties.
The DOM has its origins in the MSIE version 4 browsers. Version 3 of MSIE and versions of Netscape prior to version 6 implement a more miscellaneous collection of objects that behave a bit like a DOM but are not really a standards-compliant model.
There are areas where the so called DOM support in each browser is so different as to render any script access to the document either problematical or virtually impossible with the same script. This means that you need to support parallel development of HTML and JavaScript to be able to cover both competing browsers.
Now that Netscape 6.0 converges on the same standards-based DOM model as MSIE, we can look forward to a much more portable future for our scripts. So long as we can disregard legacy versions and steer clear of the still quite large number of differences, we should be able to to do much more across different browsers without needing to code differently for each one. History suggests it is also equally likely that they will diverge in other areas where they introduce new features.
The starting point for the DOM hierarchy is the <HTML> HTML tag, although the <BODY> HTML tag is realistically the root of the DOM.
Until the version 5/6 browsers ship, the existing DOM support is referred to as Level 0. The current standard is level 1 and level 2 is on the horizon.
The basic approach to the DOM differs between the browsers on these points:
Netscape prior to version 6.0 generally provides a constructor for every object type. MSIE only provides them for objects that you can reasonably instantiate. The new Netscape should comply with the DOM requirements and only provide constructors where they are mandated by the standard.
MSIE implements an Element object on which most other DOM components are based. Netscape 6 implements a structured, DOM compliant model so this is implicit.
The DOM hierarchy is organized in different ways. MSIE provides many reference vectors for locating parent and child objects to traverse the DOM tree. Netscape provides very few prior to version 6.0.
MSIE provides an object to represent every tag. Its type is the tag name in upper case.
On the down-side, MSIE supports a DOM structure that resembles the DOM standard quite closely. However, many of its class names are incorrect. Netscape 6.0 supports a similar structure but uses the correct names for object classes. If you need to use class names in your scripts, beware!
This is not supported at all on Netscape 2 and 3 or MSIE version 3. You should at least check for these browsers and generate a helpful warning message or skip round the requirement somehow.
See also: | Compatibility, Document object, DOM, Event handler scope |
Prev | Home | Next |
Doctype.notations[] | Up | document |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |