User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,804 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,873 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 4676 | Replies: 3
Reply
Join Date: Jul 2007
Location: france
Posts: 2
Reputation: jeremusic is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jeremusic jeremusic is offline Offline
Newbie Poster

Question javascript function not working in firefox

  #1  
Aug 7th, 2007
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,resizab

le=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>	
<!-- 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><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 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 -->
Attached Files
File Type: php menuDW.php (42.4 KB, 2 views)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Rep Power: 5
Solved Threads: 34
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: javascript function not working in firefox

  #2  
Aug 7th, 2007
Use Firefox's built in JavaScript console. It will tell you what the error is.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote  
Join Date: Jan 2007
Posts: 2,556
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 115
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: javascript function not working in firefox

  #3  
Aug 8th, 2007
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.
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Jul 2007
Location: france
Posts: 2
Reputation: jeremusic is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jeremusic jeremusic is offline Offline
Newbie Poster

Re: javascript function not working in firefox

  #4  
Aug 8th, 2007
Thanks for your replies. I'll check out the advice and get back to you! :-)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:36 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC