日期:2014-05-16 浏览次数:20364 次
<style> div{ width:200px; height:100px; } </style> <div id="div1" style="border:1px solid black;"></div> <div id="divmsg"></div> <script> window.onload = function(){ var obj = document.getElementById("div1"); var crtstyle = obj.currentStyle || obj.ownerDocument.defaultView.getComputedStyle(obj, null);// 前者用于IE,后者FF var str = ""; for(var e in crtstyle){ str += e + " === " + crtstyle[e] + "<br/><br/>"; } document.getElementById("divmsg").innerHTML = str; } </script>
------解决方案--------------------
http://www.phpx.com/man/dhtmlcn/objects/currentStyle.html
currentStyle是只读的
------解决方案--------------------
getComputedStyle应是除IE外都支持的
------解决方案--------------------
找 最终样式