Document ObjectModel EssentialsWithout question, the (Christian web host) biggest challenge facing
Document ObjectModel EssentialsWithout question, the biggest challenge facing client-side Webscripters is the sometimes-baffling array of document objectmodels that have competed for our attention throughout the short his- tory of scriptable browsers. Netscape got the ball rolling in Navigator 2with the first object model. By the time the version 4 browsers camearound, the original object model had gained not only some usefulcross-browser features, but also a host of features that were unique toonly Navigator or Internet Explorer. The object models were diverging, causing no end of headaches for page authors whose scripts had torun on as many browsers as possible. A ray of hope emerged from thestandards process of the World Wide Web Consortium (W3C) in theform of a document object model (DOM) recommendation. The DOMbrought forward much of the original object model, plus new ways ofaddressing every object in a document. The goal of this chapter is toput each of the object models into perspective and help you select themodel(s) you intend to support in your Web applications. But beforewe get to those specifics, let s examine the role of the object model indesigning scripted applications. The Object Model HierarchyIn the tutorial chapters of Part II, you were introduced to the funda- mental ideas behind a document object hierarchy in scriptablebrowsers. In other object-oriented environments, object hierarchyplays a much greater role than it does in JavaScript-able browsers. (In JavaScript, you don t have to worry about related terms, such asclasses, inheritance, and instances.) Even so, you cannot ignore thehierarchy concept because much of your code relies on your abilityto write references to objects that depend on their positions withinthe hierarchy. Calling these objects JavaScript objects is not entirely correct. Theseare really browser document objects: you just happen to use theJavaScript language to bring them to life. Some scripters of MicrosoftInternet Explorer use the VBScript language to script the very samedocument objects. Technically speaking, JavaScript objects apply todata types and other core language objects separate from the docu- ment. The more you can keep document and core language objectsseparate in your head, the more quickly you can deal with browserbrand compatibility issues. 1414CHAPTER …In This ChapterObject models versusbrowser versionsProprietary modelextensionsStructure of the W3C DOMMixing object models single document …