Javascript Reference
Categories: STYLE

javascript STYLE runtimeStyle

@March 15, 2008, 1:22 a.m.
runtimeStyleFirefox/Netscape/NN n/a IE 5 Chrome/Safari/DOM n/a  


Returns a style object whose individual style properties convey values only if they are explicitly set via the regular style sheet processes. Unlike the currentStyle object, system default style sheet properties are not reflected. You can set individual style properties of this runtimeStyle object, but doing so transcends (some might say violates) normal cascading precedence. Any property you assign by script overrides all other settings for that style property governing that element, including values assigned to the element tag's style attribute and style property. For example, if you assign the value red to an element's style.color property, and assign the value green to the same element's runtimeStyle.color property, the element's text appears in green, even though the more specific style.color property still preserves the red value. At that point the element's currentStyle.color property also returns green, because that is the effective style governing the element at that instant.


You can use the runtimeStyle object to assign multiple style properties by reassigning a CSS syntax rule to the runtimeStyle.cssText property. Assign an empty string to the cssText property to remove all in-line attribute values, allowing the regular style sheet cascade to control the element's effective style.

document.getElementById("elementID").runtimeStyle.cssText =
		  "border: 5px blue solid";

style object reference.


The effective style object and its explicitly defined style attribute values.

Powered by Linode.