0

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 -->

Edited by pritaeas: Closed for new replies

Attachments
<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>&nbsp;
			</td>
		</tr>
		<tr>
			<td valign="top">
				<form name="testage">
					<input type="hidden" name="code" value="0">
				</form>	
<!-- Prsentation -->  
				<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>Prsentation</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><br /><br />
														</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 gnrales
											</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');">Actualits passes</a></li></td></tr>-->
								</table>
							</a>
						</ul>
					</ul>
				</a>
<!-- Economie -->
				<a href="#" onclick="if (VersionNavigateur(3.0,4.0))  
						img10.src='imgs/fl_b.gif';montre('smenu1');
						img11.src='imgs/fl_d.gif';cache('smenu2');
						img12.src='imgs/fl_d.gif';cache('smenu3');
						img13.src='imgs/fl_d.gif';cache('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');
						img21.src='imgs/fl_d.gif';cache('smenu12');">
					<ul>
						<li class="menu">
							<table cellspacing=0 border=0>
								<tr>
									<td width=22 align=center><img name="img10" 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="economie/commerce/c_1.php" target="centre" onclick="cache('smenu12')"><b>Economie</b>
										</a>
									</td>
								</tr>
							</table>
						</li>
						<ul id="smenu1">
							<table cellspacing=0 cellpadding=0 border=0>
								<tr>
									<a href="#" onclick="if (VersionNavigateur(3.0,4.0))  
img21.src='imgs/fl_d.gif';cache('smenu12');">
									<td width=15>
									</td>
									<td valign=top width=10 class="titre">-
									</td>
									<td class="titre">
										<a href="economie/commerce/c_1.php" target="centre" onclick="cache('smenu12');">Les entreprises, commerants et artisans
										</td></a>
									
								</tr>
								<tr>
									<td width=15>
									</td>
									<td valign=top width=10 class="titre">-
									</td>
									<td class="titre">
										<a href="economie/e_3.html" target="centre" onclick="cache('smenu12');">Foire et Marchs
										</a>
									</td>
								</tr>
								<tr>
									<a href="#" onclick="if (VersionNavigateur(3.0,4.0))  
img21.src='imgs/fl_b.gif';montre('smenu12');">
										<td width=15>
										</td>
										<td valign=top width=10><img name="img21" 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 1 -->
											<a href="economie/e_2_1.html" target="centre" onclick="montre('smenu12');">Maison pour l'emploi
											</a>
											<ul id="smenu12">
<!-- Empeche l'a
3
Contributors
3
Replies
5
Views
10 Years
Discussion Span
Last Post by jeremusic
0

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.

0

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