DHTML Methods
Recalculates all dynamic properties in the current document.
document.recalc ( [ bForceAll ] )
bForceAll |
Optional. If set to TRUE, this method will evaluate all expressions in the document. If set to FALSE, the default, only those expressions that reference properties that have changed since the last recalculation will be recalculated. |
No return value.
Note This method is an extension of Microsoft's® implementation of the generic DOM Level 2 CSS Interfaces, for use with the expanded capabilities of Internet Explorer® 5 and later.
Implicit dependencies, internal property changes, and related properties may result in some expressions not being recalculated even though the properties they reference may have changed.
Implicit dependencies refer to properties that may be altered by changes in other properties. For instance, the height of a DIV is implicitly dependent upon the innerHTML of the DIV. However, if an expression references the height, a change in the innerHTML ( which may alter the height ) would not cause a recalculation of the expression on a subsequent call to recalc.
Internal property changes may not prompt recalculations of expressions referencing such properties on subsequent calls to recalc. For instance, resizing the main window changes document.body.clientWidth. Expressions that reference clientWidth may not get recalculated because the change may not be recognized.
Related properties are properties that access or manipulate data or behavior that is also accessed or manipulated by one or more other properties. For instance, both pixelLeft and posLeft set or retrieve the left position of the element. However, if an expression references element.pixelLeft and element.posLeft is altered, the expression may not be recalculated on subsequent calls to recalc.
Related properties that may result in this behavior include:
clientHeight, clientLeft, clientTop, clientWidth, height, left, offsetHeight, offsetLeft, offsetTop, offsetWidth, pixelHeight, pixelLeft, pixelTop, pixelWidth, posHeight, posLeft, posTop, posWidth, top
To guard against these issues, authors should refer to the same property name or manually call recalc ( true ) to force recalculations of all expressions.
Dynamic properties behavior of Internet Explorer® 5 will recognize and recalculate related properties, implicit dependencies, and internal property changes.
The following sample code fragments illustrate the implementation of recalc in both HTML and scripting.
The following sample code illustrates the HTML implementation of recalc.
<p>The sum of the values in these two text boxes
determines the width of the colored text box.</p>
<div align="center">
<input size=4 id="Box1" value=40>
<input size=4 id="Box2" value=40>
<br><br>
<input type=text id="Box3"
style="width:expression ( eval ( Box1.value ) +
eval ( Box2.value ) );background:silver">
</div>
Show me
The same functionality can be implemented in client-side script as shown in the following code.
<script language="JavaScript">
function numOnly ( ) {
window.status=event.keyCode;
if ( ( event.keyCode-48>=0 ) && ( event.keyCode-48<=9 ) ) {
event.returnvalue=true;}
else{
event.returnvalue=false;
alert ( 'Only numbers are accepted' ) }
}
</script>
<body>
<div align="center">
<input onkeypress="numOnly ( )" size=4 id="Box1"
value=40>
<input onkeypress="numOnly ( )" size=4 id="Box2"
value=40><br><br>
<input type=text id="Box3" style="background:gold">
</div>
</body>
Show me
The following example shows how to define a style that works in previous versions of Internet Explorer. This sample HTML will position the DIV at 200px, 200px on Internet Explorer® 4.0 but animate over time on Internet Explorer® 5.
<div style="position:absolute; top:200px;
left:200px; left:function ( time.ms / 100 );" />
Show me
document
Dynamic Properties, getExpression, removeExpression, setExpression