James H. Zisch - Computer Services

Support : Guides

 

Javascript® & DOM (Document Object Model)

Beginning with Microsoft Internet Explorer® 4.x and Netscape Navigator/Communicator® 4.x browsers referencing browser components/objects began support for utilization of DOM (Document Object Model). As per the standard, previous access technique is to be supported for backward compatibility; however, testing for the presence of DOM remained recommended to assure 100% backward compatibility across all browsers and platforms. For some time there remained distinct variations between implementations of the standard not to mention browser specific extensions outside the scope of the standard with additional variations across different versions, releases as well as platforms. Now, these variations to the standard are for all intents and purposes eliminated. However, it still is wise to test thoroughly when deploying these more advanced methodologies most especially for mission critical components.

The most significant difference between the original techniques of manipulating browser components using Javascript®/Jscript® versus using the DOM techniques is accessing objects, methods and properties. Prior to DOM, objects were referenced by "Name". This technique was limited as not all elements/objects supported the "Name" attribute. And, reference by "Name" also required knowing the object's parent object in order to reference the object. DOM introduced the concepts of an object "ID" permitting direct access to an object without having to know in advance its parent/child relationship in the object hierarchy to gain access. As part of that initial DOM implementation supporting reference by "ID" is the document method "getElementByID". Being at the document level combined with the restriction that the "ID" attribute must be unique within the scope of the document eliminated the need to know the object's relationship in the document hierarchy. And, "getElementsByName" document method was also introduced; note the plural of "Elements" as it returns an array of references.

DOM is much more powerful than simply supporting direct access to objects. It provides the ability to tranverse the entire hierarchical structure of browser objects and elements as well as to create portions or entire documents dynamically using scripts. DOM, as its name implies, provides dynamic capabilities of the client-side of the Internet client-server environment. Combining the user of the W3C DOM, CSS (Casading Style Sheets), and Javascript (or ECMA Script) provides what is commonly referred to as Dynamic HTML (DHTML).

Add to the DOM environment data formatted in XML (Extended Markup Language) and these capability begin to expand significantly. Support for the Extended HTML (XHTML) standard further expands on these capabilities with the more current DOM standard and its complementary ECMA Script standard combine in supporting traversal and creation of data in XML format.

This only begins to scratch the surfaces of these improved refinements and developments. And, the work goes on.

Learn more about DOM by visiting W3C (World Wide Web Consortium) for the current standard and revision drafts. Previously, JHZ-CS would have recommended also considering the references and resources available at the Netscape® and Microsoft® developer website; however, this is no longer the case. Microsoft® implementation of a substantial set of platform specific extensions to the standard remains proprietary resulting in deployments only supported on the Microsoft® computer platform. Many of the capabilities being built into the new standards are a direct result of Microsoft® extensions and they should be commended; however, JHZ-CS always recommends keeping deployment of propreitary and platform specific extensions to a bare minimum to keep future design considerations simplified and costs down. And, I mentioned no longer recommending Netscape developer resources. Well, regrettably, in late 2004 those resources where taken offline permanently. However, you are in luck as the W3C has done a slendid job of refining their formats making them usable to all.

NOTE: Refer to W3C's (World Wide Web Consortium) "Intrinsics" (Chapter 18 - Scripts) in the most current HTML approved standard for aspects specific to web device/browser scripting as it pertains to HTML elements. (Javascript® is a registered trademark of Netscape Communications Corp.; JScript® is a registered trademark of Microsoft Corp.)