Skip to content

Instantly share code, notes, and snippets.

@joseadrian
Created November 27, 2013 21:22
Show Gist options
  • Save joseadrian/7683436 to your computer and use it in GitHub Desktop.
Save joseadrian/7683436 to your computer and use it in GitHub Desktop.
getComputeStyle IE support. getcomputedStyle(element, pseudo class)
// http://stackoverflow.com/questions/15733365/cross-browser-ie8-getcomputedstyle-with-javascript#comment23187887_15733365
// http://snipplr.com/view/13523/
if (!window.getComputedStyle) {
window.getComputedStyle = function(el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop == 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
}
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment