if(window.getComputedStyle){//FF,chrome
var getStyle = function(dom,name){
var doms = window.getComputedStyle(dom,null);
//var name = name.replace(/([A-Z])/g,"-$1").toLowerCase();
//var value = doms.getPropertyValue(name);
if(name=="float"){
name = "cssFloat";
}
var value = doms[name];
return value;
}
}else if(document.documentElement.currentStyle){//IE
var curStyle = function(dom,name){
var doms = dom.currentStyle;
if(name=="float"){
name = "styleFloat";
}
//var value = doms.getAttribute(name);
var value = doms[name];
return value;
}
}
var cssValue = getStyle||curStyle;
属性名使用驼峰写法,getPropertyValue取值时使用的参数名是与CSS样式名一样的,如果使用中括号取值float需转换styleFloat或者cssFloat,不能使用.(点)取值,因为点无法取得变量的值