spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column75


Netscape 6, Part IV: DOM Differences and Commonalities with IE5.x

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

The Lower Root Node

You can use the DOM to model an entire document. At the root of document model is the document object. But this node is only virtual: you cannot display its type, name, or ID. You can access these properties through the documentElement object attribute. Internet Explorer 5.x and Netscape 6 are compatible when you access the documentElement object, as opposed to the document object, which is not supported well by Internet Explorer 5.x. The examples in this page should work in both browsers. If you query the name of document.documentElement:

document.documentElement.nodeName

you would get HTML. Try it. You may also query the root's type:

document.documentElement.nodeType

You should get 1. Try it. There are three types:

  • 1 = Tag (Examples: HTML, BODY, HEAD)
  • 2 = Attribute (Examples: ID, NAME, BGCOLOR)
  • 3 = Text (Free text between opening and closing tags. Example: text between <P> and </P>)

The node document.documentElement is the root of the document model. If you would query its first child:

document.documentElement.firstChild.nodeName

you would get the HEAD tag. Try it.

Next: How to use the ownership relationship

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: January 15, 2001
Revised: January 15, 2001

URL: http://www.webreference.com/js/column75/3.html