JavaScript Editor JavaScript Debugger     JavaScript Editor 



Team LiB
Previous Section Next Section

Summary

The DOM represents a bright future for JavaScript, where the intersection between script, HTML, and style sheets is cleanly defined. Using the DOM and JavaScript, we are no longer restricted to making minor modifications to a Web page. We can access any tag in a document using methods added to the Document object, like getElementById(), getElementsByName(), and getElementsByTagName(). Once elements have been accessed, their attributes and contents can be modified. We can create tags and text fragments on the fly, even going so far as to create a brand new HTML document from scratch. This is the real promise of Dynamic HTML.

Unfortunately, the DOM is not well supported yet. The 6.x generation of browsers has good support for DOM Level 1, but support for CSS manipulations is still a bit buggy. Even when supported by browsers, the DOM presents significant challenges. First, HTML syntax will have to be much more strictly enforced if scripts are to run correctly. The execution of a script using the DOM on a poorly formed document is, in the words of the W3C itself, “unpredictable.” Second, JavaScript programmers will have to become intimately familiar with tree manipulations. Given these restrictions, we probably won’t see every JavaScript developer making a mad-dash for the DOM, and the old-style objects and access methods will most likely live on for some time. As we work through the practical applications in the next part of the book, we will often see a contrast between the DOM methods presented in this chapter and traditional JavaScript programming methods. However, before presenting these applications, we need to cover one last topic—event handling.


Team LiB
Previous Section Next Section


JavaScript Editor JavaScript Debugger     JavaScript Editor


©

R7