Section 2.5. Static W3C HTML DOM Objects


2.5. Static W3C HTML DOM Objects

One category of DOM object not explicitly detailed in this chapter is the one containing the static DOM objects from which each HTML element object instance is derived. By and large you won't ever have need to script these static objects directly, although you will see their names crop up in your debugging in browsers such as Mozilla and recent versions of Safari and Opera. For example, if you ask the alert( ) method to display the reference to a p element object in Mozilla, the reference is converted to a string form as follows:

 [object HTMLParagraphElement] 

This is not the object's JavaScript type (which is just object). But it means that the p element in question is an instance of the W3C DOM HTMLParagraphElement object. In browsers that support direct access to the static object (Mozilla, Safari after version 2.0.4, and Opera 8 or later), you have the luxury of adding properties and methods to the prototype property of any such object. Thus, any new instance that your scripts create has those new properties and methods built into them (see the Array.prototype description in Chapter 5 for an example of this JavaScript mechanism).

The W3C DOM Level 2 module for HTML elements defines the static objects in the following list. All of these objects inherit the properties and methods of the HTMLElement object, also listed below. Descriptions for these items can be found later in this chapter under the HTML element object names (e.g., HTMLParagraphElement is covered under the p object).

HTMLAnchorElement
HTMLAppletElement
HTMLAreaElement
HTMLBaseElement
HTMLBaseFontElement
HTMLBodyElement
HTMLBRElement
HTMLButtonElement
HTMLDirectoryElement
HTMLDivElement
HTMLDListElement
HTMLElement
HTMLFieldSetElement
HTMLFontElement
HTMLFormElement
HTMLFrameElement
HTMLFrameSetElement
HTMLHeadElement
HTMLHeadingElement
HTMLHRElement
HTMLHtmlElement
HTMLIFrameElement
HTMLImageElement
HTMLInputElement
HTMLIsIndexElement
HTMLLabelElement
HTMLLegendElement
HTMLLIElement
HTMLLinkElement
HTMLMapElement
HTMLMenuElement
HTMLMetaElement
HTMLModElement
HTMLObjectElement
HTMLOListElement
HTMLOptGroupElement
HTMLOptionElement
HTMLParagraphElement
HTMLParamElement
HTMLPreElement
HTMLQuoteElement
HTMLScriptElement
HTMLSelectElement
HTMLStyleElement
HTMLTableCaptionElement
HTMLTableCellElement
HTMLTableColElement
HTMLTableElement
HTMLTableRowElement
HTMLTableSectionElement
HTMLTextAreaElement
HTMLTitleElement
HTMLUListElement

When a browser implements an element that is not part of the HTML 4 and W3C DOM specification, it typically extends the HTMLDivElement or HTMLSpanElement object with behaviors and/or styles to give that elements it's special characteristics. Thus, Mozilla reports that a marquee element is derived from the HTMLSpanElement object.




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