Chapter 15. Generic HTML Element Objects


  • Working with HTML element objects

  • Common properties and methods

  • Event handlers of all element objects

The object model specifications implemented in Internet Explorer 4 or later and W3C/Mozilla-based browsers feature a large set of scriptable objects that represent what we often call generic HTML elements. Generic elements can be divided into two groups. One group, such as the b and strike elements, defines font styles to be applied to enclosed sequences of text. The need for these elements (and the objects that represent them) is all but gone due to more page designers using style sheets. The second group of elements assigns context to content within their start and end tags. Examples of contextual elements include h1, blockquote, and the ubiquitous p element. Although browsers sometimes have consistent visual ways of rendering contextual elements by default (for example, the large bold font of an <h1> tag), the specific rendering is not the intended purpose of the tags. No formal standard dictates that text within an em element must be italicized: The style simply has become the custom since the very early days of browsers.

All of these generic elements share a large number of scriptable properties, methods, and event handlers. The sharing extends not only among generic elements, but also among virtually every renderable element—even if it has additional, element-specific properties, methods, and/or event handlers that I cover ...

Get JavaScript® Bible, Sixth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.