Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

divs work in IE6 but not FF

Status
Not open for further replies.

lastdonuk

Programmer
Jan 19, 2005
58
GB
Hi,

I've inherited a website which is causing me a particular problem by not functioning correctly in firefox.
As an experiment, I recreated the problem code in Dreamweaver MX using the design view to see how IE6 & Firefox 1.0.4 handled it. IE works fine - it's 3 radio buttons each showing a layer on click of the corresponding button, the page is here:

div.htm

However, this code does not function in FF, I'm wondering if it's some problem with the javascript setting the layers to be visible/invisible? The code is here:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Layers - crossbrowser</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if

((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;

onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)

location.reload();
}
MM_reloadPage(true);

function setvisible(Layer)
{
appname = navigator.appName;

    if (appname == "Microsoft Internet Explorer")
    {
        Layer.style.visibility = "visible";
    }
    else
    {
        setinvisible(Layer);
        Layer.visibility = true;
    }
}

function setinvisible(Layer)
{
appname = navigator.appName;
    if (appname == "Microsoft Internet Explorer")
    {
        Layer.style.visibility = "hidden";
    }
    else
    {
        setinvisible(Layer);
        Layer.visibility = false;
    }
}

//-->
</script>
</head>
<body>
<form name="form1" method="post" action="">
  <p>
    <label>
    <input type="radio" name="r1" value="noadv"

onClick="setvisible(Layer1);setinvisible(Layer2);setinvisible(Layer3)">
    option 1</label>
    <br>
    <label>
    <input type="radio" name="r1" value="advref"

onClick="setvisible(Layer2);setinvisible(Layer1);setinvisible(Layer3)">
    option 2</label>
    <br>
    <label>
    <input type="radio" name="r1" value="broker"

onClick="setvisible(Layer3);setinvisible(Layer2);setinvisible(Layer1)">
    option 3</label>
    <br>
  </p>
  <div id="Layer1" style="position:absolute; width:200px; height:115px;

z-index:1; left: 154px; top: 19px; visibility: hidden;">
    <div align="center">1</div>
  </div>
  <div id="Layer2" style="position:absolute; width:200px; height:115px;

z-index:2; left: 156px; top: 21px; visibility: hidden;">
      <div align="center">2</div>
  </div>
  <div id="Layer3" style="position:absolute; width:200px; height:115px;

z-index:3; left: 155px; top: 22px; visibility: hidden;">
    <div align="center">3</div>
  </div>
  <p>&nbsp; </p>
</form>
</body>
</html>

I've read alot of generalities about the problems with divs in FF, but can't work out which aspect of the code is the issue. I've posted this on a couple of the forums as I'm not sure as to the exact issue. Any pointers in the right direction here would be greatly appreciated.

Thanks.
 
I think the problem is your setinvisible function. If the app isn't IE then the first thing it does is call itself again - you get into an infinite loop!

Looking at it, I don't quite see the need to call another function, in either setvisible or set invisible. Try just having:

Code:
function setvisible(Layer)
{
appname = navigator.appName;

    if (appname == "Microsoft Internet Explorer")
    {
        Layer.style.visibility = "visible";
    }
    else
    {
        Layer.visibility = true;
    }
}

--James
 
Many thanks James, I'll try that out & get back to you.
 
Thanks for your help James, I posted this on the javascript forum (forum 216) too and had two other suggestions for this which can be viewed at thread216-1065490.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top