javascript - Trying to Understand How jQuery calculates computed properties for IE8 using currentStyle -
i'm trying understand how jquery arrives @ pixel values ie8 when dealing non-pixel based property values, such margin-top: 2em
, or height: auto
. ie9+, getcomputedstyle()
can provide easily, in case of ie8, currentstyle
not. trying arrive @ solution can calculate total height of element, including css height, padding, border, , margin browsers ie8+. have come across following answer, can't understand going on in accepted answer.
cross-browser (ie8-) getcomputedstyle javascript?
i wondering if explain going on in code?
here shim computed style webplatform.
if (!window.wpo) { window.wpo = {}; } if (!wpo.utils) { wpo.utils = {}; } wpo.utils.getcomputedstyle = function(_elem, _style) {// wpo getcomputedstyle shim. var computedstyle; if (typeof _elem.currentstyle != 'undefined') { computedstyle = _elem.currentstyle; } else { try{computedstyle = document.defaultview.getcomputedstyle(_elem, null);}catch(e){return '';} } return computedstyle[_style]; }
Comments
Post a Comment