关于js中取非行间样式的兼容问题

来源:互联网 发布:植发失败 知乎 编辑:程序博客网 时间:2024/06/03 17:01

取行间样式的方法一般有两种, currentStyle和getComputedStyle,但是火狐和chrome都不支持currentStyle,我们的方法是用if

if(oDiv.currentStyle)

{  alert( oDiv.currentStyle,width ) ; }

else

{ alert (getComputedStyle(oDiv,false).width ); }//第二个参数(false)可以随便是什么 


需注意的是这个只能是取单一样式,像width、color这种,而不能取复合样式,像background。

0 0