From: http://www.javaeye.com/topic/166395
备忘一下:)
<script type="text/javascript">

var mydiv=document.getElementById("test")

function getCurrentStyle(obj, cssproperty, csspropertyNS){
	if(obj.style[cssproperty]){
		return obj.style[cssproperty];
	}
	if (obj.currentStyle) {// IE5+
		return obj.currentStyle[cssproperty];
	}else if (document.defaultView.getComputedStyle(obj, null)) {// FF/Mozilla
		var currentStyle = document.defaultView.getComputedStyle(obj, null);
		var value = currentStyle.getPropertyValue(csspropertyNS);
		if(!value){//try this method
			value = currentStyle[cssproperty];
		}
		return value;
	}else if (window.getComputedStyle) {// NS6+
		var currentStyle = window.getComputedStyle(obj, "");
		return currentStyle.getPropertyValue(csspropertyNS);
	}
}
alert(getCurrentStyle(mydiv, "backgroundColor", "background-color")); //alerts "yellow"
</script>
评论
发表评论

您还没有登录,请登录后发表评论

liudaoru
搜索本博客
最近加入圈子
存档
最新评论