js获取非行内样式

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>获取非行内样式</title>
<style>
#w{width:100px;}
</style>
</head>
<body>
<div id="w">
</div>
<script>
function sCss(){
var oD=document.getElementById("w");
if(oD.currentStyle)
{
  //ie
  alert(oD.currentStyle.width);
}
else {
  //firefox
  alert(getComputedStyle(oD,
false).width);
} } sCss();
</script> </body> </html>

//getComputedStyle 指元素的最终样式
//currentStyle IE专用
原文地址:https://www.cnblogs.com/dream-w/p/4807036.html