SiteExperts.com Logo Home | Community | Developer's Paradise | Jobs
User Groups | Site Tools | Site Information | Search

Inside Technique : Using Dynamic Expressions
By Scott Isaacs

IE5's Dynamic Expressions are a great way to add custom style to your web-pages. Dynamic Expressions are essentially script that automatically execute when a property is being evaluated. In this article we introduce you to Dynamic Expressions and how to apply them to extend CSS with powerful new features.

Web-page scripts have traditionally fallen into one of two types - scripts that execute to write content into the page as it loads and event-oriented where the script runs in response to an event on the page. For example, a script that is event-oriented may execute when the page finishes loading or the user clicks on a hyperlink. Event-drive scripting is most effective when the script responds to user interaction. To use these scripting models to apply logic to your page's rendering you either have to compose the page entirely of script or to change the page after it has loaded.

In this article we explore a new IE 5 script technique, Dynamic Expressions. With Dynamic Expressions, you can associate CSS properties with script that is automatically executed as your page renders. We start with a simple scenario demonstrating how to highlight the current page in a menu. We continue by demonstrating the power of Dynamic Expressions to manipulate style based on content and document structure. Keep in mind while your read this article that the demonstrations only work in IE 5.0 or later.

We now continue with a simple demonstration of Dynamic Expressions.

Page 1:Using Dynamic Expressions
Page 2:Highlighting the Current Page
Page 3:Style based on Content
Page 4:Style based on Structure