setExpression method
9 |
Sets a dynamic expression for the specified DHTML property on the current element.
The support for dynamic properties has been removed in Internet Explorer 9, so none of the getExpression, removeExpression, setExpression and recalc methods are supported.
These methods exist in version 8, but using them raises exceptions.
Dynamic expressions (also called dynamic properties) provide a way to specify script expressions for the values of DHTML properties.
These expressions are recalculated automatically, but if necessary, they can be explicitly updated with the recalc method.
To get an expression, use the getExpression method, to remove it, use the removeExpression method.
See the example below for details.
Dynamic expressions are also supported for the values of style properties.
If you need further information about it, see the pages for the styleObj.getExpression, styleObj.removeExpression and styleObj.setExpression methods.Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. String that specifies the name of the DHTML property. This parameter is not case-sensitive. The available property names can be found on the JavaScript pages for the HTML objects. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Required. String that specifies the script expression for the value of the style property. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Optional. String that specifies the language of the expression script.
One of the following values:
|
Return value:
This method has no return value.
Example HTML code 1:
This example illustrates the use of dynamic expressions for DHTML properties:
|
||||
<head> <script type="text/javascript"> // Try..catch blocks need to be used because of Internet Explorer 8 function GetExp () { var input2 = document.getElementById ("input2"); try { var expression = input2.getExpression ("value"); alert ("Expression is: " + expression); } catch (e) { alert ("Your browser does not support the getExpression method!"); } } function SetExp () { var input1 = document.getElementById ("input1"); var input2 = document.getElementById ("input2"); try { input2.setExpression ("value", "input1.value"); } catch (e) { alert ("Your browser does not support the setExpression method!"); } } function RemoveExp () { var input2 = document.getElementById ("input2"); try { input2.removeExpression ("value"); } catch (e) { alert ("Your browser does not support the removeExpression method!"); } } </script> </head> <body onload="SetExp ()"> When the contents of the first input field are modified, the second input field will be synchronized. <input id="input1" /> <input id="input2" /> <br /><br /><br /> With the following buttons, you can get, remove and set the expression that synchronizes the value:<br /> <button onclick="GetExp ()">Get expression!</button> <button onclick="SetExp ()">Set expression!</button> <button onclick="RemoveExp ()">Remove expression!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
a, abbr, acronym, address, applet, area, b, base, basefont, bdo, bgsound, big, blockquote, body, br, button, caption, center, cite, code, col, colgroup, comment, dd, del, dfn, dir, div, dl, dt, em, embed, fieldset, font, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:hidden, input:image, input:password, input:radio, input:reset, input:submit, input:text, ins, isindex, kbd, label, legend, li, link, listing, map, marquee, menu, meta, nobr, noframes, noscript, object, ol, optgroup, option, p, param, plaintext, pre, q, rt, ruby, s, samp, script, select, small, span, strike, strong, style, sub, sup, table, tbody, td, textarea, tfoot, th, thead, title, tr, tt, u, ul, var, wbr, xml, xmp
Related pages:
External links:
User Contributed Comments