Click to See Complete Forum and Search --> : pls help, cross browser problem


olace
09-14-2004, 06:48 PM
Can someone please help me with my javascript code to work in other browsers besides Internet Explorer. (eg firefox).



You can view the page here: http://www.factoryfestival.org/text.htm



And my problem code is:

<SCRIPT language="JavaScript">
<!--
function changetable()
{
if (document.all)
{
var box1= eval ('document.all.boxbox1.style');
var box2= eval ('document.all.boxbox2.style');
box1.backgroundColor="#DDBEBF";
box2.backgroundColor="#CCB7B8";
}
}

function changetableorig()
{
if (document.all)
{
var box1= eval ('document.all.boxbox1.style');
var box2= eval ('document.all.boxbox2.style');
box1.backgroundColor="#D4AFB0";
box2.backgroundColor="#C3A8A9";
}
}
//-->
</SCRIPT>


<td id="boxbox1" onMouseover="changetable();" onMouseout="changetableorig();" width="495" height="35" bgcolor="#D4AFB0" style="text-align:justify">
<td id="boxbox2" onMouseover="changetable();" onMouseout="changetableorig();" width="65" bgcolor="#C3A8A9" style="text-align:justify">

Jona
09-14-2004, 07:15 PM
You should start by using valid HTML (http://validator.w3.org) and Cascading Stylesheets (http://www.w3.org/Style/CSS) for layout and design.


<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Untitled Document.</title>
<script type="text/javascript"><!--
function changetable()
{
if (document.all)
{
var box1=document.all.boxbox1.style;
var box2=document.all.boxbox2.style;
} else if(document.getElementById){
var box1=document.getElementById('boxbox1').style;
var box2=document.getElementById('boxbox2').style;
} else if(document.layers) {
var box1=document.layers["boxbox1"].style;
var box2=document.layers["boxbox2"].style;
}
box1.backgroundColor="#DDBEBF";
box2.backgroundColor="#CCB7B8";
}

function changetableorig()
{
if (document.all)
{
var box1=document.all.boxbox1.style;
var box2=document.all.boxbox2.style;
} else if(document.getElementById){
var box1=document.getElementById("boxbox1").style;
var box2=document.getElementById("boxbox2").style;
} else if(document.layers){
var box1=document.layers["boxbox1"].style;
var box2=document.layers["boxbox2"].style;
}
box1.backgroundColor="#D4AFB0";
box2.backgroundColor="#C3A8A9";
}
//--></script>
</head>
<body>
<td id="boxbox1" onmouseover="changetable();" onmouseout="changetableorig();" style="text-align:justify; background: #D4AFB0; width: 495px; height: 35px;">
<td id="boxbox2" onmouseover="changetable();" onmouseout="changetableorig();" style="text-align:justify; background: #C3A8A9; width: 65px;">
</body>