function $(id){return document.getElementById(id);}
function getStyle(elem,name){
if(elem.style[name]){
return elem.style[name];
}else if(elem.currentStyle){
return elem.currentStyle[name];
}else if(document.defaultView && document.defaultView.getComputedStyle){
name = name.replace(/([A-Z])/g,"-$1").toLowerCase();
var s = document.defaultView.getComputedStyle(elem,'');
return s && s.getPropertyValue(name);
}else{
return null
}
}
alert(getStyle($('box'),'height'));
alert(getStyle($('box'),'width'));
详细解决方案
获取真实的式样值
热度:154 发布时间:2012-11-08 08:48:11.0
相关解决方案