DHTML Methods
DOM Level 2 Specification.
Removes an expression from the given CSS property.
bSuccess = object.removeExpression ( sPropertyName )
sPropertyName |
Required. Name of the property from which to remove an expression. |
Boolean. Returns true if the expression was successfully removed, or false if it was not successfully removed.
This method deletes a CSS property if it has been explicitly set within the declaration block.
The value of the property after the expression has been removed is equal to the last computed value of the expression. Expressions set by the setExpression method can be removed only by invoking removeExpression.
The removeExpression method applies to the style subobject and can be used to remove expressions from supported CSS Attributes. This method is also available in scripting for the innerHTML and value attributes.
Using removeExpression in script:
object.removeExpression ( sProperty, sExpression,
sLanguage )
Using removeExpression on a style:
object.style.removeExpression ( sProperty, sExpression,
sLanguage )
This method is Microsoft's® implementation of the generic removeProperty interface provided for in the DOM.
The following sample code illustrates the implementation of removeExpression. The blue box's width is defined as an expression equal to the sum of the two values in the first two text boxes. The first button brings up an alert box revealing the expression for the width of the blue box. The second button removes the expression. The third button brings up another alert box revealing the expression for the width of the blue box. However, the blue box no longer has an expression for its width, so getExpression returns undefined. Note that after the expression is removed, the value for the blue box's width property remains equal to the last calculated value of the expression.
Sample Code
<div align="center">
<input size=4 id="Box1" value=40>
<input size=4 id="Box2" value=40><br>
<input size=4 id="Box3" style="background:blue">
<p></p>
<input type=button id="Button1"
value="Get expression" onclick="getexp ( )">
<p></p>
<input type=button id="Button2"
value="Remove expression" onclick="remexp ( )">
</div>
<script language="JavaScript">
<!--
var s;
var b;
Box3.style.setExpression ( "width", "eval ( Box1.value ) +
eval ( Box2.value )", "jscript" );
function getexp ( ) {
s=Box3.style.getExpression ( "width" );
alert ( "Expression for the width of the blue box is"+
"\n\n"+ s + "\n\n"+
"The width property has a value of "+
Box3.style.width );
}
function remexp ( ) {
b = Box3.style.removeExpression ( "width" );
alert ( "Expression removed successfully? \n" + b );
}
//>
</script>
Show me
Dynamic Properties, getExpression, recalc, setExpression