Click to See Complete Forum and Search --> : Style Function Problem


JusCoolin
12-07-2003, 11:09 PM
I have the following code that is not working. I simply want the background color of the cell to change when the mouse goes over the link. I can't seem to get this to work!


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.tdlink {
color:black;
font-family:Verdana;
background-color: #FFFFFF;
}
-->
</style>
<SCRIPT language="JavaScript">
<!--
function change_bkgrd(the_cell)
{
if (document.layers)
{
if (document.getElementById(the_cell).backgroundColor = "#FFFFFF")
document.getElementById(the_cell).backgroundColor = "#CCFFFF";
}
if (document.all)
{
if (document.all.GetElementByID(the_cell).style.backgroundColor = "#FFFFFF")
document.all.GetElementByID(the_cell).style.backgroundColor = "#CCFFFF";
}
}

//-->
</SCRIPT>
</head>

<body>
<table>
<tr>
<td name="c1" id="c1" class="tdlink">
<a href="somepage.cfm" onMouseOver="change_bkgrd('c1')" onMouseOut="change_bkgrd_back('c1')">Link</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>
</table>
</body>
</html>

Anybody have any ideas? Thanks!

skriptor
12-08-2003, 01:12 AM
Hi,
this version works in IE and Netscape 7.1 ( both are using else-path )

function change_bkgrd(the_cell)
{
if (document.layers)
{
if (document.getElementById(the_cell).backgroundColor = "#FFFFFF")
document.getElementById(the_cell).backgroundColor = "#CCFFFF";
} else {
if (document.getElementById(the_cell).style.backgroundColor = "#FFFFFF")
document.getElementById(the_cell).style.backgroundColor = "#CCFFFF";
}
}


Good luck, skriptor