spacer

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

home / experts / javascript / column40


The Document Object Model (DOM), Part I (2)

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

The DOM vs the DHTML Object Model

The Document Object Model evolved from the DHTML Object Model, but one may argue that it is more like a revolution than an evolution. The DHTML Object Model lets you access and update HTML objects individually. Each HTML tag can be accessed and manipulated via its ID and NAME attributes. Each object sports its own properties, methods, and events. You can use the properties to read and update local attributes of the object. You can use the methods to manipulate the object, and take advantage of the events to trigger pre-defined consequences.

The Document Object Model is much more general than the DHTML Object Model. It provides a model for the whole document, not just for a single HTML tag. The Document Object Model represents a document as a tree. Every node of the tree represents an HTML tag, or a textual entry inside an HTML tag. The tree structure accurately describes the whole HTML document, including relationships between tags and textual entries on the page. A relationship may be of the type child, parent, or sibling.

You need a manual to access and update an HTML page with the DHTML Object Model. The reason being that each tag's object includes different properties, methods, and events. There are tens of HTML tags and tens of properties, methods, and events per each. Most relevant textbooks include an object map that helps you find the right property, method, or event for your particular need. You don't need any manual to access and update an HTML page with the Document Object Model. When looking at HTML code, you can figure out what the tree model of the page looks like, and how to navigate to the properties you need. The Document Object Model allows you to update every textual entry on the page, and only textual entries. To change a textual entry with the DHTML Object Model, most objects support the innerHTML property which you can access and update. To change a textual entry with the Document Object Model, you just change the value of the relevant tree node with the nodeValue property.

The Document Object Model allows you to navigate along the document tree, up and down, and to the sides. You can use the child, parent, and sibling relationships to go from anywhere to anywhere on your page tree. The DHTML Object Model does not include a tree representation of the page and thus does not provide any navigation capabilities. Once you start with a tag's object, you cannot move to other tags in its vicinity. Certain tags, such as the <TABLE> tag, provides specific properties and methods to reach content elements, but the representation is not as consistent and intuitive as that of the Document Object Model. In the case of the <TABLE> tag, for example, you need to look up in the manual and find out that the textual entry of the i,j cell can be accessed via tableObj.rows[i].cells[j].innerHTML. You don't need any manual to access it via the Document Object Model. Just look at the HTML code and you can access every field there with simple navigation steps.

The Document Object Model lets you manipulate the document tree. You can create new nodes, delete existing nodes, and move nodes around the tree. The semantics of these operations is exactly what it seems. They add new tags, delete existing tags, and move tags around the document. The DHTML Object Model does not let you modify the document. When using the DHTML Object Model, you are limited to the object you are working with.

The Document Object Model has one deficiency with respect to the DHTML Object Model: it does not support event handling. The DHTML Object Model provides a wide spectrum of events and event handling capabilities for the document's objects. Since you can't do much without event handling, you'll have to keep your DHTML expertise intact.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Crucial Triples Up With New Three-Channel DDR3 Kits · Meet the Finalists: Excellence in Technology Awards · Tealeaf Offers Insight to Mobile Customer Behavior


Created: May 31, 1999
Revised: May 31, 1999

URL: http://www.webreference.com/js/column40/domvsdhtml.html