
正文
从css样式表中抽取元素尺寸
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
jS从样式表取值的函数。IE中以currentStyle,firefox中defaultView来获取
DOM.style仅仅能读到写在html中的样式值
获取样式值的函数
function returnStyle(obj,styleName){
var myObj = typeof obj =="string" ?
document.getElementById(obj) : obj;
if(document.all){
return eval("myObj.currentStyle."+ styleName);
} else {
returneval("document.defaultView.getComputedStyle(myObj,null)." +styleName);
}
}







