Collections in Dynamic HTML
HTML Coder
By Rob Falla
Dynamic HTML (DHTML) is a rather cool technology that allows you to change the appearance of an HTML document on the fly and to create dynamic content, such as animated text, on a single page. Rather than loading a series of HTML pages to create dynamic content, DHTML lets you define objects on a single page that can change over time. You can then manipulate these objects via collections.
In this article, I'll take a brief look at the DHTML event-handling and object model, show how you can do simple things like alter font colors, and then explore collections. Note that although DHTML is based on the World Wide Web Consortium's Cascading Style Sheets standard, the two major browser manufacturers support DHTML differently. I'll focus on Microsoft's implementation here.
Handling Events
DHTML works by placing an event handler in the start tag of an HTML element, or tag. Events such as onMouseOver, onMouseOut, and onClick are fired by either a user action or a timer event. The browser calls the function associated with the event handler and tells it to execute. When the script contained within the function runs, it can change the currently displayed elements: text size and color, background, tag contents, and so on. The browser repositions other elements to make the altered element fit while repainting the appropriate section of the document. Only changed or moved elements are repainted.
The event handler has an attribute value that provides the name of the function.