| home / programming / professional / chap6/ 2 | [previous] [next] |
|
|
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. |
| length |
The number of elements
in the all[] collection. |
| tags[] |
An array with all
tags of one kind. |
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 | [previous] [next] |
Created: March 11, 2003
Revised: March 28, 2003
URL: http://webreference.com/programming/professional/chap6/2