相关疑难解决方法(0)

使用Javascript跨浏览器(IE8-)getComputedStyle?

由于IE8不支持getComputedStyle,我们只能使用currentStyle.但是,它不会返回某些属性的实际"计算"值.

例如:

<style type="text/css">
#div {/* no properties are defined here */}
</style>
Run Code Online (Sandbox Code Playgroud)
<div id="div">div</div>
Run Code Online (Sandbox Code Playgroud)
// 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
Run Code Online (Sandbox Code Playgroud)

有没有人在不使用jQuery或其他Javascript库的情况下为所有属性提供跨浏览器解决方案?

javascript internet-explorer styles cross-browser

23
推荐指数
3
解决办法
2万
查看次数