↑
Main Page
DOM Support
The W3C has also published language-specific DOMs defined for SVG (
http://www.w3.org/TR/
SVG
), SMIL Animation (
http://www.w3.org/TR/smil-animation
), and MathML (
http://
www.w3.org/TR/MathML2
).
DOM Support
As I said previously, not all browsers are at the same level of DOM support. Generally speaking, Mozilla
has the best DOM standards support, supporting almost all DOM Level 2 and parts of DOM Level 3.
Behind Mozilla, Opera and Safari have made significant inroads toward closing the support gap, sup-
porting almost all DOM Level 1 and most of DOM Level 2. Lagging behind the field is Internet Explorer,
whose incomplete implementation of DOM Level 1 leaves much to be desired.
Using the DOM
Even though the
document
object is considered part of the BOM, it is also is a representation of the HTML
DOM’s
HTMLDocument
object, which, in turn, is also an XML DOM
Document
object. Most DOM manipu-
lation in JavaScript makes use of the
document
object, so that’s a logical place to begin the discussion.
Accessing relative nodes
Consider the following HTML page for the next few sections:
<html>
<head>
<title>DOM Example</title>
</head>
<body>
<p>Hello World!</p>
<p>Isn’t this exciting?</p>
<p>You’re learning to use the DOM!</p>
</body>
</html>
To access the
<html/>
element (which you should realize is the
document
element of this file), you can
use the
documentElement
property of
document
:
var oHtml = document.documentElement;
Because of an incorrect DOM implementation, Internet Explorer 5.5 returns the
<body/>
element for
document.documentElement
. Internet Explorer 6.0 fixes
this problem.
167
DOM Basics
09_579088 ch06.qxd 3/28/05 11:37 AM Page 167
Free JavaScript Editor
Ajax Editor
©
→