IHTMLStyle2::setExpression method
[This documentation is preliminary and is subject to change.]
Sets an expression for the specified object.
Syntax
Integer setExpression(
[in] BSTR sPropertyName,
[in] BSTR sExpression,
[in, optional] BSTR sLanguage = JScript
);
Parameters
sPropertyName [in]
BSTR that specifies the name of the property to which expression is added.
sExpression [in]
BSTR that specifies any valid script(JScript, JavaScript, VBSCript) statement without quotations or semicolons. This string can include references to other properties on the current page. Array references are not allowed on object properties included in this script.
sLanguage [in, optional]
BSTR that specifies one of the following values:
JScript
Default. Language is JScript.
VBScript
Language is VBScript.
JavaScript
Language is JavaScript.
Remarks
Use the setExpression method to add expressions to supported Cascading Style Sheets (CSS) attributes and read/write DHTML Properties. To remove expressions set by setExpression, use the removeExpression method.
The following syntax sections show how to set an expression on DHTML Properties and CSS attributes.
Use this syntax to set an expression on a read/write property or on an expando property.
object.setExpression(sPropertyName, sExpression, sLanguage)Use this syntax to set an expression on a CSS attribute.
object.style.setExpression(sPropertyName, sExpression, sLanguage)Use the expression() syntax to set an expression on a CSS attribute in HTML.
<ELEMENT STYLE="sAttributeName:expression(sExpression)">
The data type of the evaluated expression in the language parameter must match one of the possible values allowed for the expression parameter. If the property or attribute specified by the first parameter requires a string, the data type of the second parameter must be a string. Otherwise, the second parameter is evaluated prior to invoking setExpression, causing the expression to be set to the result of the evaluation.
Use the uniqueID property of an object in an expression to refer back to the object. Using uniqueID is an alternative to specifying an id for expressions that use an object reference.
The cssText property is a unique property that is not compatible with the dynamic properties implementation. Do not use cssText with any dynamic property methods.
The following examples illustrate common problems encountered with the expression parameter in setExpression. The expression appears valid, but may not be.
The provided expression is invalid because document.style.fontSize is "npx" and will not add to 13
object.style.setExpression("height","document.style.fontSize + 13");The provided expression is invalid when document.body.style.fontSize is previously unspecified
object.style.setExpression("width","document.body.style.fontSize");
Requirements
Minimum supported client |
Windows XP |
Minimum supported server |
Windows 2000 Server |
Header |
|
DLL |
Mshtml.dll |
See also
Reference
Conceptual
Build date: 1/23/2012