Using firefox 5 when i run
window.getComputedStyle(document.getElementsByTagName("img")[0], null);
I get the complete css file, instead of the styles applied onto the “img” tag.
I ran this on https://developer.mozilla.org/en/DOM/window.getComputedStyle
Anyone knows of a workaround?
I know this is an older post, but for anyone landing here.
Basic idea: you need to call the
getPropertyValue()method on the object returned bywindow.getComputedStyle().See this fiddle: http://jsfiddle.net/zupa/jyyt9/
MDN states you don’t need to call
document.defaultView.getComputedStyle()butwindow.getComputedStyleNote that window.getComputedStyle() returns used values not computed values. (See previous link.)
Compatibility tables: MDN, quirksmode