JavaScript Bible Example Book
Document object models for both IE4+ and NN6 expose all
HTML elements as scriptable objects. A beneficial
byproduct of this concept is that object model designers find it
easier to implement their models according to genuinely objectoriented
principles. (In truth, modern HTML and DOM industry
standards encourage browser makers to think in object-oriented
terms anyway.) The object-oriented principle most applicable to
the way we work with objects is that all HTML elements inherit
properties, methods, and event handlers from a generic (and
unseen) HTML element object. Thus, specifications for any
HTML element object start with those of the generic object, and
then pile on element-specific features, such as the src property
of an IMG element. This chapter deals almost exclusively with
the properties, methods, and event handlers that all HTML
elements have in common.
Examples Highlights
✦ Modern object models and the scripting world now pay
much attention to the containment hierarchy of elements
and text nodes in a document. The function
shown in Listing 15-3 demonstrates how vital the
childNodes property is to scripts that need to inspect
(and then perhaps modify) page content.
✦ Element containment is also at the forefront in Listing
15-10, where W3C DOM syntax demonstrates how to use
the firstChild and lastChild properties, plus the
insertBefore(), appendChild(), and replaceChild()
methods, to change portions of page content on the fly.
✦ In the IE/Windows world, data binding can be a powerful
tool that requires only tiny amounts of your code in a
page. You can get a good sense of the possibilities in
the extended examples for the dataFld and related
properties.
You can download this book
No comments:
Post a Comment