This documentation is archived and is not being maintained.

DHTML Behaviors

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Microsoft® Internet Explorer 5 or later 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. When 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 or later 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 make it possible for the user to save selected stock symbols with the user's page.

In addition, you can 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 to associate the behavior with an HTML element.

See Also

Why Build Your Own Objects? | Basic Class Concepts | Creating Property Procedures | Creating Events and Event Procedures | Extending Objects Through Interfaces | Designing Object Models | Creating Custom Objects for Web Pages | Using Web Technologies

Show: