Click to See Complete Forum and Search --> : problem with Netscape


tregi
11-26-2003, 01:30 AM
Hi iīve problem with this code of folder menu...
it works under IE but under Netscape 6.0 or 7.1 donīt...
Have somebody any solve?
----
the code is here
----

<html>
<HEAD>

<title>Brot</title>


<script language="javascript">
<!--
var Open = ""
var Closed = ""

function preload(){
if(document.images){
Open = new Image(15,15)
Closed = new Image(15,15)
Open.src = "arrow_down.gif"
Closed.src = "arrow.gif"
}}


function showhide(what,what2){
if (what.style.display=='none'){
what.style.display='';
what2.src=Open.src
}
else{
what.style.display='none'
what2.src=Closed.src
}
}
-->
</script>

<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="stylesheet" TYPE="text/css" HREF="main.css">

</HEAD>



<body onload="preload()" marginheight="0" marginwidth="0" bottommargin="0" topmargin="0" rightmargin="0" leftmargin="0"
alink="#000000" link="#000000" vlink="#000080" bgcolor="FFFAA9" >


<table cellspacing="2" cellpadding="1" border="0" style="font-size:12; font-family:Verdana;">
<tr >
<td width="170" background="obr/bg_table.gif" bgcolor="FFFAA9" valign="top" >

<span id="menu1" onClick="showhide(menu1outline,menu1sign)" style="cursor:hand; font-Family:Verdana; font-size:12; font-weight:bold"><font style="text-decoration:none">
<img id="menu1sign" src="arrow.gif" valign="bottom"> </font>Menu</span><br>
<span id="menu1outline" style="display:'none'">

<span id="menu1_1" onClick="showhide(menu1_1outline,menu1_1sign)" style="cursor:hand; font-Family:Verdana; font-size:12; ">
<font style="text-decoration:none">
&nbsp;&nbsp;<img id="menu1_1sign" src="arrow.gif" valign="bottom"> Menu 1_1
</font></span>
<br>
<span id="menu1_1outline" style="display:'none'; font-size:12;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="">Menu 2_1</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="">Menu 2_2</a><br>
</span>


</span>



</td>

</tr>
</table>


</body>
</html>

-------
thx a lot
:)

Gollum
11-26-2003, 03:27 AM
I have some solve...

There are two problems I can see.

The first is regarding styles:
<span id="menu1outline" style="display:'none'">
you shouldn't have the ' quotes around the none. And beware, this display type is not supported by netscape before version 6.

The second is regarding your onclick code...
showhide(menu1outline,menu1sign)
"menu1outline" is the id of the span you want to control. To get the HTMLElement with that id, use getElementById(). IE is just being very nice to you by letting you refer to it like that.

Here's your code with those fixes in...

<html>
<HEAD>

<title>Brot</title>


<script language="javascript">
<!--
var Open = ""
var Closed = ""

function preload()
{
if(document.images)
{
Open = new Image(15,15);
Closed = new Image(15,15);
Open.src = "arrow_down.gif";
Closed.src = "arrow.gif";
}
}


function showhide(what,what2)
{
var oWhat = document.getElementById(what);
var oWhat2 = document.getElementById(what2);
if (oWhat.style.display=='none')
{
oWhat.style.display='';
oWhat2.src=Open.src
}
else
{
oWhat.style.display='none'
oWhat2.src=Closed.src
}
}
-->
</script>

<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="stylesheet" TYPE="text/css" HREF="main.css">

</HEAD>
<body onload="preload()" marginheight="0" marginwidth="0" bottommargin="0" topmargin="0" rightmargin="0" leftmargin="0" alink="#000000" link="#000000" vlink="#000080" bgcolor="FFFAA9" >
<table cellspacing="2" cellpadding="1" border="0" style="font-size:12; font-family:Verdana;">
<tr>
<td width="170" background="obr/bg_table.gif" bgcolor="FFFAA9" valign="top">
<span id="menu1" onClick="showhide('menu1outline','menu1sign')" style="cursor:hand; font-Family:Verdana; font-size:12; font-weight:bold">
<font style="text-decoration:none">
<img id="menu1sign" src="arrow.gif" valign="bottom">
</font>
Menu
</span>
<br>
<span id="menu1outline" style="display:none">
<span id="menu1_1" onClick="showhide('menu1_1outline','menu1_1sign')" style="cursor:hand; font-Family:Verdana; font-size:12; ">
<font style="text-decoration:none">
<img id="menu1_1sign" src="arrow.gif" valign="bottom">
Menu 1_1
</font>
</span>
<br>
<span id="menu1_1outline" style="display:none; font-size:12;">
<a href="">Menu 2_1</a><br>
<a href="">Menu 2_2</a><br>
</span>
</span>
</td>
</tr>
</table>
</body>

</html>

tregi
11-26-2003, 04:06 AM
wow!!
man thx a lot :)

Gollum
11-26-2003, 04:47 AM
no probs tregi :cool:

gil davis
11-26-2003, 12:31 PM
<body onload="preload()" ...>
Running a "preload" script onload defeats the purpose of doing the preload.