Так как IE8 не поддерживает getComputedStyle
, мы можем использовать только currentStyle
. Однако он не возвращает реальное "вычисленное" значение для некоторых свойств.
Например:
<style type="text/css">
#div {/* no properties are defined here */}
</style>
<div id="div">div</div>
// returns "medium" instead of 0px
document.getElementById('div').currentStyle.borderLeftWidth
// returns "auto" instead of 0px
document.getElementById('div').currentStyle.marginLeft
// returns "undefined" instead of 1
document.getElementById('div').currentStyle.opacity
У кого-нибудь есть кросс-браузерное решение для всех свойств без использования jQuery или других библиотек Javascript?