Chapter 2. Document Object Model Reference


This chapter focuses on objects in documentsthe scriptable entities that a browser maintains in its memory whenever a document is loaded. Most of these objects are created for you when the browser interprets the tags embedded within the content of the document. But many more objects exist solely for the purposes of scripting activities, such as event processing, window manipulation, creating and populating documents with new objects, reading the client's system environment, and even XML data that is part of an AJAX exchange with a server.

An object is described by its properties, methods, collections (or arrays) of nested items, and events. The Dynamic HTML features that you associate with a document rely entirely upon the objects and the properties, methods, and events that are supported by the browsers used by the page's visitors. The scriptable object model of early browsers was a simple one, with relatively few objects, and those objects had short lists of implemented properties, methods, and events. Today's model, however, is huge, due to a greatly expanded object model for Microsoft Internet Explorer 4 and, more recently, the addition of a completely new (and still growing) abstract object model designed by the W3C. That newest object model, the W3C DOM, is the model for which any new DHTML scripting should be targeted, as it is supported to various extents by all modern mainstream scriptable browsers.

To help you choose the right objects, properties, methods, and event handlers for the type of page development you're doing, this chapter lists every client-side Dynamic HTML-related object defined by Microsoft (IE), pre-Mozilla Netscape (NN), Mozilla (Moz), Safari (Saf), Opera 7 or later (Op), and the W3C (DOM), including some DOM Level 3 modules nearing completion. From these listings, you should be able to judge whether a particular object or its properties, methods, or events will work for your application.

If cross-browser support is essential for your application, pay close attention to the browser support and version information for each entry. The version number represents the first version of a particular browser to support the term (Opera compatibility ratings begin with version 7). Where no implementation exists, I use "n/a" to indicate that. Items valid for only a single version show the number encased in pipe symbols (e.g., |4|: for Version 4 only). For derivatives of the Mozilla Foundation's browser (e.g., Firefox, Netscape 6 or later, Camino, etc.), see Appendix F. Be aware that some items may not be available on all operating system platforms for a particular browser brand and version (particularly true for Internet Explorer 5). These distinctions are noted wherever the anomalous behavior could be substantiated by actual testing on the Win32 and Macintosh platforms. For example, IE 5 means both Windows and Mac versions, while IE 5(Win) is Windows only; IE 5.5 or later are Windows only.

Following a section that lists properties, methods, and events shared by all HTML element objects in the latest browsers, this chapter is organized alphabetically by object type. HTML element object types appear as their corresponding HTML element's tag name (in XHTML lowercase form). Scripts do not reference elements by these names, except when they use tag name strings as method parameters (e.g., document.getElementsByTagName("h1")). Instead, scripts reference such element objects by the various ways that scripts produce valid references to element objects. The most common is to assign an identifier to the id attribute of the element, and use that identifier to create a reference with syntax such as the following W3C DOM method:

 document.getElementById("elementID") 

where the parameter is a string of the element's identifier. Numerous other properties throughout the object models evaluate to valid element object references, without requiring an explicit reference to the identifer. For example, an event object contains a property that evaluates to a valid reference to the element that was the target of the event. A script statement can then use that reference to access the element object's properties or methods, as needed.

The very large W3C DOM vocabulary contains many terms that do not come into common use even in today's browsers. For example, the element object listed in this chapter as the div object is formally known in the W3C DOM as the HTMLDivElement object. For the sake of compactness, this chapter does not list the W3C DOM HTML element objects as separate entries, but see "Static W3C HTML DOM Objects" below for further details.




Dynamic HTML. The Definitive Reference
Dynamic HTML: The Definitive Reference
ISBN: 0596527403
EAN: 2147483647
Year: 2004
Pages: 120
Authors: Danny Goodman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net