| | |
javascript function not working in firefox
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2007
Posts: 2
Reputation:
Solved Threads: 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.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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> </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 -->
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!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
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.
- 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
![]() |
Similar Threads
- database connection(select ,insert query) within javascript function (JSP)
- Javascript Function to reload DOM Element? (JavaScript / DHTML / AJAX)
- Javascript not working in Firefox (JavaScript / DHTML / AJAX)
- javascript works in IE but not working in firefox (JavaScript / DHTML / AJAX)
- DateTime - TimeZone conversion with Javascript. Partially working! (JavaScript / DHTML / AJAX)
- changing font type working in IE not in firefox (HTML and CSS)
- javascript code not working in mozillafirefox (JavaScript / DHTML / AJAX)
- my php session_destroy() function not working (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Problem in Default Value of Check Box
- Next Thread: image gallery help
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column cookies createrange() css cursor debugger dependent disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math media microsoft mimic object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post problem programming progressbar regex runtime scroll search security select session shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






