Re-Using HTML Code

The power of the DHTML object model is emphasized by scripting code that adds a level of interactivity and flexibility. You should know by now about the advantages of scripting, since it's not a new issue.

However, what's really new is that scripting the DHTML object model provides a considerably larger range of choices, and—consequently—increases the possible applications by several orders of magnitude. Simply put, DHTML allows you to be much more creative when developing scripting code.

A primary reason for this increased expressiveness is the ability you now have to change the HTML source code dynamically. You can add new features or simply modify the attributes of existing tags. A revolutionary opportunity!

For instance, with DHTML you can have bitmapped anchors that look like buttons when pressed and released. To get this result, you no longer need specialized components such as ActiveX controls. Now, it can all be done in pure DHTML code.

The end point of this discussion is the reusability of HTML source code. Have you got the idea? You're given the opportunity to write powerful and commercial-quality code that can manipulate the structure and the events of any page at its leisure. It does it by adding, replacing and removing everything—from ActiveX controls to scripts, and from text to images and links.

So why not try to encapsulate these routines into reusable pieces of code? When a development language grows beyond a certain threshold, as for the number of basic objects and its general complexity, it poses the problem of writing really reusable code.

With the addition of DHTML object model, HTML has undoubtedly exceeded this limit. As a consequence, you cannot keep on cut-and-pasting handy utilities every time you need them: you need a quicker, easier and more elegant solution.

As you've probably guessed, scriptlets are just this: a clean, terse, and pretty cool way of designing full HTML objects, built on the top of DHTML object model.

© 1997 by Wrox Press. All rights reserved.