Microsoft Office 2000/Visual Basic Programmer's Guide |
Internet Explorer 5 supports DHTML behaviors. DHTML behaviors are lightweight, reusable components that encapsulate specific functionality or behavior on a page. You apply a behavior to a standard HTML element on a page to enhance that element's default functionality. Once you have defined a custom DHTML behavior, you or other people on your Web development team can easily apply the behavior to achieve custom interactive effects across multiple pages, without having to write script.
Internet Explorer 5 implements several default behaviors. For example, the saveFavorite behavior saves the current state of a page when it is added to the Favorites list. You can use the saveFavorite default behavior to save information that a user has added to a Web page prior to saving it in the user's Favorites list. If your Web page provides stock information, for example, you might use the saveFavorite behavior to allow the user to save selected stock symbols with the user's page.
You can also create custom DHTML behaviors by using scriptlets. For example, you can create a behavior that affects a list item on a Web page, so that when the user rests the mouse pointer on the list item, the item changes color. To apply this behavior to a Web page, you refer to the file containing the behavior within a <STYLE> tag. The following example applies the behavior defined in a file named Hilite.sct to two list items in an HTML file:
<BODY><UL>
<LI STYLE="behavior:url(hilite.sct)">Item1
</UL></BODY>
<BODY><UL>
<LI STYLE="behavior:url(hilite.sct)">Item2
</UL></BODY>
The scriptlet that defines the behavior must implement certain tags that Internet Explorer recognizes in order to associate the behavior with an HTML element. For more information about creating and using behaviors, see the Microsoft Site Builder Workshop Web site at http://www.microsoft.com/workshop/default.asp, and see Chapter 12, "Using Web Technologies."