1 out of 2 rated this helpful - Rate this topic

runtimeStyle object

[This documentation is preliminary and is subject to change.]

Represents the cascaded format and style of the object that overrides the format and style specified in global style sheets, inline styles, and HTML attributes.

Standards information

There are no standards that apply here.

Remarks

The runtimeStyle object sets and retrieves the format and style of an object, and overrides existing formats and styles in the process. Other than having precedence over the style object and not persisting, the runtimeStyle object is equivalent to the style object.

To change or clear multiple style properties simultaneously, use this object with the cssText property. For example, to change the font color and background color of a DIV element, you could use the following code:



<DIV onclick="this.runtimeStyle.cssText = 'color:red;background-color:blue;border:5px solid black;'">
Click this DIV to change style properties.</DIV>


Examples

This example sets a value on the runtimeStyle object to affect the currentStyle object, but not the style object.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/runtimeStyle.htm


<SCRIPT>
function fnChangeValue(sValue){
   if(oDIV.runtimeStyle.backgroundColor == oDIV.style.backgroundColor){
      sValue="";
   }
   oDIV.runtimeStyle.backgroundColor = sValue;
   console.log(oDIV.style.backgroundColor +
      "\n" + oDIV.currentStyle.backgroundColor +
      "\n" + oDIV.runtimeStyle.backgroundColor);
}
</SCRIPT>
<DIV ID = "oDIV">
This is a demonstration DIV.
</DIV>
<INPUT TYPE = "button" VALUE = "Change Color" onclick="fnChangeValue('blue')">

See also

currentStyle

 

 

Build date: 3/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ