Paul Lautman wrote:
RobG wrote:
>From a Matt Kruze post (wrapped for posting);
function getObjectStyleV alue(obj,proper ty) {
[snip]
Cheers for that
Check out a more robust version at:
http://www.javascripttoolbox.com/lib/util/
// Get the currently-applied style of an object
css.getStyle = function(o, property) {
if (o==null) { return null; }
var val = null;
var camelProperty = css.hyphen2came l(property);
// Handle "float" property as a special case
if (property=="flo at") {
val = css.getStyle(o, "cssFloat") ;
if (val==null) {
val = css.getStyle(o, "styleFloat ");
}
}
else if (o.currentStyle && defined(o.curre ntStyle[camelProperty])) {
val = o.currentStyle[camelProperty];
}
else if (window.getComp utedStyle) {
val = window.getCompu tedStyle(o,null ).getPropertyVa lue(property);
}
else if (o.style && defined(o.style[camelProperty])) {
val = o.style[camelProperty];
}
// For color values, make the value consistent across browsers
// Convert rgb() colors back to hex for consistency
if (/^\s*rgb\s*\(/.test(val)) {
val = css.rgb2hex(val );
}
// Lowercase all #hex values
if (/^#/.test(val)) {
val = val.toLowerCase ();
}
return val;
};
--
Matt Kruse
http://www.JavascriptToolbox.com http://www.AjaxToolbox.com