80 Part III . Document Objects Reference Although (Web hosting rating)
80 Part III . Document Objects Reference Although the document.all collection is not implemented in the W3C DOM, use the new documentobject method (available in IE5+ and NN6+) that enables you to access any element by its ID: var elem = document.getElementById( myParagraph ) Unfortunately for scripters, this method is difficult to type (it is case-sensitive watch out for that ending lowercase d ). But the W3C DOM includes another documentobject method that enables you to simulate the document.allconvenience collection. See the section, Simulating IE4 Syntax in NN6 later in this chapter. A hierarchy of nodes The issue surrounding containers (described earlier) comes into play for the underlying architecture of the W3C DOM. Every element or freestanding chunk of text in an HTML (or XML) document is an object that is contained by its next outermost container. Let s look at a simple HTML document to see how this system works. Listing 14-1 is formatted to show the containment hierarchy of elements and string chunks. Listing 14-1: A Simple HTML Document
This is the one and only paragraph on the page.
What you don t see in the listing is a representation of the document object. The document object exists automatically when this page loads into a browser. Importantly, the document object encompasses everything you see in Listing 14-1. Therefore, the document object has a single nested element: the HTML element. The HTML element, in turn, has two nested elements: HEAD and BODY. The HEAD element contains the TITLE element, while the TITLE element contains a chunk of text. Down in the BODY element, the P element contains three pieces: a string chunk, the EM element, and another string chunk.Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.