Before IE 5, a property's value could only be set using a static variable. If you needed an element's property values to be dependent on another property value, you. d need to manually trap these state changes and perform the appropriate updates. A simpler way is to let IE take care of that for you, however there are times when an expression may not be updated automatically. If this happens just call the recalc() method and set It's parameter to true. This will cause all expression to be evaluated manually. To set a property value to an expression or formula, use either expression() or the setExpression() method. The method you use will depend on where you are setting your Dynamic Properties. If you are setting them in an embedded or inline style sheet, you need to use expressios(). When working with setting expressions in scripts, the setExpression() method is what you need to use. Once you. ve set a properties value using expression() or the setExpression() method, it becomes a Dynamic Property. let's look at how to use these methods:
This works in the same ways as when defining style for elements on your page. But, instead of entering a static value for the CSS attribute value, the expression() method along with the desired expression replaces the static value. One added advantage of using expression() is the fact that browsers that don't support Dynamic Properties will simply ignore this piece of code, this reduces your need to with any browser sniffing scripts.
With the scripting syntax, object
represents any of the DHTML objects. PropertyName represents the
read/write property of the object you are referencing. The ScriptLanguage
parameter is an optional parameter that you can use to indicate which
scripting language the expression is written in. By default, the language
is JScript, but you can also set it to JavaScript or VBScript.
Our first example uses
both setExpression() and expression() to create an interesting script that
we're sure you'll have fun playing around with.