I have a menu that uses javascript ot show and hide submenus. It works in IE but not in Firefox. I've pasted part of the code below: montre = show and cache = hide (french) i.e. used to show and hide the submenus. I attached the whole file if you need it.

<html>
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="menu.css" media="screen" title="Default">

<script language="JavaScript">
<!-- debut du script
function VersionNavigateur(Netscape, Explorer) {
if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
(navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
return true;
else return false;
}
//  fin du script -->

function montre(id) 
{ if (document.getElementById) { document.getElementById(id).style.display="block";        
} else if (document.all) {document.all[id].style.display="block";                
} else if (document.layers) 
{document.layers[id].display="block";                
} } 

function cache(id) {    
if (document.getElementById) {    
document.getElementById(id).style.display="none";    
} 
else if (document.all) {    
document.all[id].style.display="none";    
} 
else if (document.layers) {    
document.layers[id].display="none";    
} 
}
</script>
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0">
<div style="position: absolute; z-index: 2; top: 0px; left: 0px; width: 100%">
<table cellspacing=0 cellpadding=0 width=210 border=0>
<tr>
<td valign=top align=right height=169>
<a href="" onclick="window.open('bonnetg.html','','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=480,height=577,left=272,top=95.5');return false;" title="Blason de Dompierre sur Besbre">
<img src="imgs/bonnet.gif" border=0 width=140 height=169 />
</a>
</td>
</tr>
</table>
</div>

<div style="position: absolute; z-index: 1; top: 0px; left: 0px; width: 100%; height: 100%">
<table border=0 cellspacing=0 cellpadding=0 border=0 width=210 height=100%>
<tr height=190>
<td> 
</td>
</tr>
<tr>
<td valign="top">
<form name="testage">
<input type="hidden" name="code" value="0">
</form>  
<!-- Présentation -->  
<a href="#" onclick="if (VersionNavigateur(3.0,4.0))
img13.src='imgs/fl_b.gif';montre('smenu4');
img14.src='imgs/fl_d.gif';cache('smenu5');
img15.src='imgs/fl_d.gif';cache('smenu6');
img16.src='imgs/fl_d.gif';cache('smenu7');
img12.src='imgs/fl_d.gif';cache('smenu3');
img11.src='imgs/fl_d.gif';cache('smenu2');
img10.src='imgs/fl_d.gif';cache('smenu1');
img20.src='imgs/fl_d.gif';cache('smenu31');">
<ul>
<li class="menu">
<table border=0 cellspacing=0>
<tr>
<td width=22 align=center>
<img name="img13" WIDTH=15 HEIGHT=15 border=0 src="imgs/fl_d.gif" onLoad="tempImg=new Image(0,0); tempImg.src='imgs/fl_b.gif'" />
</td>
<td class="titre">
<a href="centre.html" target="centre" onclick="window.open('haut2.html','haut');cache('smenu31')"><b>Présentation</b></a>
</td>
</tr>
</table>
</li>
<ul id="smenu4">
<a href="#" onclick="if (VersionNavigateur(3.0,4.0))  img20.src='imgs/fl_b.gif';montre('smenu31');">
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=15>
</td>
<td valign=top width=10>
<img name="img20" WIDTH=10 HEIGHT=10 border=0 src="imgs/fl_d.gif" onLoad="tempImg=new Image(0,0); tempImg.src='imgs/fl_b.gif'" />
</td>
<td class="titre">
<!-- Sousmenu 2 -->
<a href="centre.html" target="centre" onclick="montre('smenu31');">Services municipaux</a>
<ul id="smenu31">
<!-- Empeche l'affichage de la ligne en selection de la cellule -->
<script language=javascript>
cache('smenu31');
</script>
<!-- Fin empechement -->
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td class="sstitre">
<a href="presentation/p_1_1.html" target="centre" onclick="window.open('haut2.html','haut')"><b>- Conseil municipal</b></a>
</td>
</tr>
<tr>
<td class="sstitre">
<a href="presentation/p_1_3.html" target="centre" onclick="window.open('haut2.html','haut')"><b>- CCAS</b></a>
</td>
</tr>
<tr>
<td class="sstitre">
<a href="presentation/p_1_4.html" target="centre" onclick="window.open('haut2.html','haut')"><b>- Commissions</b></a>
</td>
</tr>
<tr>
<td class="sstitre">
<a href="presentation/Cptrenduconseil.htm" target="centre" onclick="window.open('haut2.html','haut')"><b>- Compte-rendu du Conseil Municipal</b></a>
</td>
</tr>
<tr>
<td class="sstitre">
<a href="presentation/p_1_2.html" target="centre" onclick="window.open('haut2.html','haut')"><b>- Documents administratifs</b></a>
</td>
</tr>
</table>
</ul>
<!-- Fin sous menu 2 -->     
</td>
</tr>
<tr>
<a href="#" onclick="if (VersionNavigateur(3.0,4.0))  img20.src='imgs/fl_d.gif';cache('smenu31');">
<td width=15>
</td>
<td valign=top width=10 class="titre">-
</td>
<td class="titre">
<a href="presentation/Epertiqui.htm" target="centre" onclick="cache('smenu31');">Epertiqui
</td></a>
</tr>
<tr>
<td width=15>
</td>
<td valign=top width=10 class="titre">-
</td>
<td class="titre">
<a href="appel/a_1.html" target="centre" onclick="cache('smenu31');">Appels d'offre</a>
</td>
</tr>
<tr>
<td width=15>
</td>
<td valign=top width=10 class="titre">-
</td>
<td class="titre">
<a href="presentation/domtps.html" target="centre" onclick="cache('smenu31');">Dompierre au fil du temps</a>
</td>
</tr>
<tr>
<td width=15>
</td>
<td valign=top width=10 class="titre">-
</td>
<td class="titre">
<a href="presentation/p_1_5.html" target="centre" onclick="cache('smenu31');">Dompierre au fil de l'eau
</a>
</td>
</tr>
<tr>
<td width=15>
</td>
<td valign=top width=10 class="titre">-
</td>
<td class="titre">
<a href="presentation/wikipedia.html" target="centre" onclick="cache('smenu31');">Informations générales</a>
</td>
</tr>    
<tr>
<td width=15>
</td>
<td valign=top width=10 class="titre">-
</td>
<td class="titre">
<a href="presentation/dompierre.html" target="centre" onclick="cache('smenu31');">Association des Dompierre de France
</a>
</td>
</tr>    
<!--<tr><td width=15></td><td valign=top width=10><FONT FACE="cordial,garamond,Book Antiqua" SIZE=3 COLOR=#ffffff>-</td><td><FONT FACE="cordial,garamond,Book Antiqua" SIZE=3 COLOR=#ffffff><a href="presentation/archactu.html" target="centre" onclick="cache('smenu31');">Actualités passées</a></li></td></tr>-->
</table>
</a>
</ul>
</ul>
</a>
<!-- Economie -->

Use Firefox's built in JavaScript console. It will tell you what the error is.

I see several problems:

- You used html comments to hide part of the JavaScript. This is deprecated, and often no longer works.

- I spotted some JS errors which IE lets slip, but FF does not.

- You have some quoted content which begins on one line and ends on another. This often causes failures.

- Your if statement near the "presentation" comment is missing its begin and end braces.

Thanks for your replies. I'll check out the advice and get back to you! :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.