About Node Manipulation
DOM-2 and the W3C
The W3C (as mentioned in Chapter 1) has released specifications for how browsers should handle the Document Object Model (also known as the DOM). The DOM Level 2 specification, which became an official recommendation in November 2000, goes into more depth as to how browsers should be able to refer to and manage the content on their pages. You can find out more details about the specification at http://www.w3.org/TR/DOM-Level-2-Core/.
Although this specification has been around for years, there are still plenty of browsers in use that have incomplete or partial DOM-2 support. Before using any of these scripts, make sure that your intended audience is able to run them, or that you offer another way for older browsers to achieve the same results. Thankfully, the majority of surfers today use Internet Explorer 6+, Firefox, or Safari, which should all work just fine with these scripts.
<html> <head> <title>My page</title> </head> <body> <p>This is text on my page</p> </body> </html>
can be displayed as seen in Figure 12.1.
Figure 12.1. The tree structure, showing nodes, is just another way of looking at how an HTML page is organized.
Level three of the DOM standard became an official recommendation in April 2004. That specification is at http://www.w3.org/TR/DOM-Level-3-Core/. As with so many other parts of the W3C process, we're still a long ways off from true support in shipping browsers, so this chapter sticks to discussing DOM-2. However, if you're interested in learning more, the best place to look is at the ECMAScript bindings, which can be found at http://www.w3.org/TR/DOM-Level-3-Core/ecma-script-binding.html.