all collection on the
document object contains references to all elements in the document page.
It was a concept created by Microsoft as a way to collect all page
elements into one array, before the W3C started work on standardizing
the object hierarchy.
document.all collection was
one of the earlier methods that accessed individual elements; however,
the actual collection itself is no longer supported in many modern
browsers, such as Mozilla/Firefox. Still, the concept of being able to
access any element in the document still remains; it’s just the approach
that has changed. Now, you can use
document.getElementById, passing in the
element’s identifier to access the individual object.
10, you’ll see how other methods get all elements of a certain
tag or, given a specific name, via the
You’ll see examples of
document.all in many older scripts, when it
was used to differentiate object support in cross-browser DHTML
applications. It’s not uncommon to see code like the following:
if (document.all) elem = document.all['elemid']; else elem = document.getElementById['elemid'];
This actually works in most browsers. However, Internet Explorer
is about the only browser that supports
document.all now, so recognize it for what it
was, but don’t use it for modern applications. IE 6.x (5.x really)
getElementById, just like
Another interesting item you’ll see in both ...