Jeśli chodzi o odczytanie koloru niezależnie od metody definiowania stylu, to polecam style obliczane...
dla IE
Kod
<html>
<head>
<style type="text/css">
div.special {
background-color: red;
height: 10px;
width: 10px;
margin: 10px;
}
</style>
<script type="text/javascript">
function getBackgroundColor() {
var oDiv = document.getElementById("div1");
alert(oDiv.currentStyle.backgroundColor);
}
</script>
</head>
<body>
<div id="div1" class="special"></div>
<input type="button" value="Sprawdź kolor tła" onclick="getBackgroundColor()" />
</body>
</html>
dla FF
Kod
<html>
<head>
<style type="text/css">
div.special {
background-color: red;
height: 10px;
width: 10px;
margin: 10px;
}
</style>
<script type="text/javascript">
function getBackgroundColor() {
var oDiv = document.getElementById("div1");
alert(document.defaultView.getComputedStyle(oDiv, null).backgroundColor);
}
</script>
</head>
<body>
<div id="div1" class="special"></div>
<input type="button" value="Sprawdź kolor tła" onclick="getBackgroundColor()" />
</body>
</html>