spacer

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

home / programming / professional / chap6/ 2 To page 1To page 2current pageTo page 4To page 5To page 6To page 7To page 7To page 7
[previous] [next]

The Web Professional's Handbook: Document Object Models

Data Center Architect
The Computer Merchant, Ltd
US-MA-chelsea

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


Microsoft DOM

The Microsoft DOM, first supported by IE 4, was curiously ahead of its time. Although it doesn't offer access to text nodes, it is nonetheless much closer to the eventual W3C specification than Netscape's.

The Microsoft DOM is supported by IE 4+, Opera 7, iCab, and Omniweb. Opera 6 supports it, too, but only when the user selects " Identify as MSIE 5.0" in File > Preferences > Network > Browser identification.

The most important feature of the Microsoft DOM is the all[] collection property of the document object. As its name indicates, this all[] collection collects all elements on the page. You can specify the id or name of an object between the square brackets and immediately access the correct element.

For our simple DHTML effect discussed above, we enter the id of the element and once again change the value of its styles.

function changeIt() // Microsoft DOM
{
  document.all['testdiv'].style.left = 0;
  document.all['testdiv'].style.position = 'relative';
  document.all['testdiv'].style.font = '20px verdana,arial,helvetica';
  document.all['testdiv'].style.textAlign =  'right';
}

Note that the changing of position does not work in IE 4.

The document.all[] collection can be used to access any HTML element in the page. For instance, to access the test form we used earlier, we can use this DOM reference:

document.all['firstform']

An HTML element in the page can also have an all[] collection property. For instance:

document.all['firstform'].all['navigation']

This accesses the form element with name="navigation" within the <form> called firstform.

The document.all[] collection includes the following properties:


Property

Description

children[]

An array with all HTML tags that are children of the selected element.

For example: document.all['myName'].children[0] is the first child element of the element with name myName.

length

The number of elements in the all[] collection.

For example: document.all['myName'].length tells you the number of elements in the document with name myName.

tags[]

An array with all tags of one kind.

For example: document.all.tags['a'] gives an array of all <a> tags in the document.

The Microsoft DOM contains other interesting properties that we don't look at here, including the innerHTML property, which is explained below in the W3C DOM section.


home / programming / professional / chap6/ 2 To page 1To page 2current pageTo page 4To page 5To page 6To page 7To page 8To page 9
[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: March 11, 2003
Revised: March 28, 2003

URL: http://webreference.com/programming/professional/chap6/2