Skip to content

Instantly share code, notes, and snippets.

@andreiglingeanu
Last active December 13, 2015 20:48
Show Gist options
  • Save andreiglingeanu/4972293 to your computer and use it in GitHub Desktop.
Save andreiglingeanu/4972293 to your computer and use it in GitHub Desktop.
getComputedStyle for IE
function getIEComputedStyle(elem, prop) {
var value = elem.currentStyle[prop] || 0
// we use 'left' property as a place holder so backup values
var leftCopy = elem.style.left
var runtimeLeftCopy = elem.runtimeStyle.left
// assign to runtimeStyle and get pixel value
elem.runtimeStyle.left = elem.currentStyle.left
elem.style.left = (prop === "fontSize") ? "1em" : value
value = elem.style.pixelLeft + "px";
// restore values for left
elem.style.left = leftCopy
elem.runtimeStyle.left = runtimeLeftCopy
return value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment