//*** This code is copyright 2003 by Gavin Kistner, !@phrogz.net //*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt //*** Reuse or modification is free provided you abide by the terms of that license. //*** (Including the first two lines above in your source code satisfies the conditions.) // Cross-browser compatible script for finding the current style applied to an // element, either explicitly or through CSS rules; // Works on IE and Mozilla; always returns 'null' for Safari function CurrentStyle(el,prop) { var viewCSS = (typeof document.defaultView=='function') ? document.defaultView() : document.defaultView; if (viewCSS && viewCSS.getComputedStyle){ var s = viewCSS.getComputedStyle(el,null); return s && s.getPropertyValue(prop); } return el.currentStyle && (el.currentStyle[prop] || null) || null; } // e.g. // var myObj = document.getElementById('foo'); // var theColorOfMyObj = CurrentStyle(myObj,'color');