This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.


Method of css/cssom/methodscss/cssom/methods


var object = object.getExpression(PropertyName);




String that specifies the name of the property from which to retrieve the expression.

Return Value

Returns an object of type DOM NodeDOM Node

A variant value representing the expression of the property.


The following examples demonstrate how to use the getExpression method to retrieve CSS properties. This example retrieves the width property of a span object.

<span id="trueBlueSpan"
    style="background-color:lightblue; width:100px">
    The width of this blue span is set inline at 100 pixels.
<span id="oldYellowSpan" style="background-color:lightyellow;
    The width of this yelllow span is set inline at 200 pixels.
<span id="AlGreenSpan" style="background-color:lightgreen;
    width:expression( +">
    Click the button below to see the expression used to set
    the width of this span.
<button onclick=alert("width"));>
    See Expression</button>

In the following example, the setExpression method is used to set the width property of a blue input type=text object equal to the sum of the values in two other input type=text objects. When the user clicks the input type=button element, the getExpression method is used to display the expression.

<script language="JScript">
var s;
function fnInit() {"width","eval(Box1.value) + eval(Box2.value)",
function getexp() {"width");
alert("Expression for the width of the blue box is \n\n" + s +
"\n\nThe width property has a value of " +;
<body onload=fnInit();>
<input type=text id="Box1" value=40>
<br><input type=text id="Box2" value=40>
<br><input type=text id="Box3" style="background-color:blue">
<br><input type=button id="Button2" value="Get expression" onclick="getexp()">

View live example



The following syntax sections show how to retrieve an expression from supported Cascading Style Sheets (CSS) and DHTML Properties.

  • Use this syntax to retrieve an expression from a read/write property or from an expando property.

var sExpression = object.getExpression(sPropertyName)

  • Use this syntax to retrieve an expression from a CSS attribute.

var sExpression =

See also

Related pages