Shim for Javascript getComputedStyle().getPropertyValue()

- - | Comments

After looking around online, attempting to sharpen my google-fu, I couldn’t find any real cross browser implementations of getComputedStyle().getPropertyValue().

I was able to find two options, both of which make the same mistake when it comes to camel casing of properties in < IE9.

Sadly, IE expects the camel cased version of the CSS property name, i.e. “marginTop” instead of “margin-top”. Every other browser that supports window.getComputedStyle or document.defaultView.getComputedStyle, uses the hyphenated syntax. I have chosen to have this script expect hypenated css properties, but it could easily be extended to accept either format.

Comments