I’m trying to get the text color in Safari. The attributes for both divs are specified in the style section. In addition for div2 the color is also specified in HTML inline style.
When div1 is clicked the alert message doesn’t give the color but the color is given when div2 is clicked. In other words the javascript doesn’t seem to be reading the color specified in the style section.
When I try this with IE (and using currentStyle in place of style) the alert gives the color for both divs.
What do I need to do to get the text color in Safari (apart from using inline style).
[CODE]<!DOCTYPE html>
<html>
<head><title>Text Color</title>
<script language=”javascript”>
function getColor(el){
var d = document.getElementById(el);
alert(d.id + ” text color is ” + d.style.color);
}
</script>
<style type=”text/css”>
.divClass {
height: 50px;
top: 100px;
width: 100px;
font-family: “Arial”;
font-size: 24pt;
font-weight: bold;
text-align: center;
background-color: #ffffff;
color: #0000ff;
position: absolute;
}
#div1 {
left: 100px;
}
#div2 {
left: 300px;
}
</style>
</head>
<body>
<div id=”div1″ class=”divClass” onClick=”getColor(id)”>TEXT1</div>
<div id=”div2″ class=”divClass” onClick=”getColor(id)” style=”color: #0000ff”>TEXT2</div>
</body>
</html>