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
Reply

Join Date: Jul 2007
Posts: 2
Reputation: jeremusic is an unknown quantity at this point 
Solved Threads: 0
jeremusic jeremusic is offline Offline
Newbie Poster

javascript function not working in firefox

 
0
  #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.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1">
  4. <link rel="stylesheet" type="text/css" href="menu.css" media="screen" title="Default">
  5.  
  6. <script language="JavaScript">
  7. <!-- debut du script
  8. function VersionNavigateur(Netscape, Explorer) {
  9. if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||
  10. (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
  11. return true;
  12. else return false;
  13. }
  14. // fin du script -->
  15.  
  16. function montre(id)
  17. { if (document.getElementById) { document.getElementById(id).style.display="block";
  18. } else if (document.all) {document.all[id].style.display="block";
  19. } else if (document.layers)
  20. {document.layers[id].display="block";
  21. } }
  22.  
  23. function cache(id) {
  24. if (document.getElementById) {
  25. document.getElementById(id).style.display="none";
  26. }
  27. else if (document.all) {
  28. document.all[id].style.display="none";
  29. }
  30. else if (document.layers) {
  31. document.layers[id].display="none";
  32. }
  33. }
  34. </script>
  35. </head>
  36.  
  37. <body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0">
  38.  
  39. <div style="position: absolute; z-index: 2; top: 0px; left: 0px; width: 100%">
  40. <table cellspacing=0 cellpadding=0 width=210 border=0>
  41. <tr>
  42. <td valign=top align=right height=169>
  43. <a href=""
  44.  
  45. onclick="window.open('bonnetg.html','','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizab
  46.  
  47. le=no,copyhistory=no,width=480,height=577,left=272,top=95.5');return false;" title="Blason de Dompierre sur
  48.  
  49. Besbre">
  50. <img src="imgs/bonnet.gif" border=0 width=140 height=169 />
  51. </a>
  52. </td>
  53. </tr>
  54. </table>
  55. </div>
  56.  
  57. <div style="position: absolute; z-index: 1; top: 0px; left: 0px; width: 100%; height: 100%">
  58. <table border=0 cellspacing=0 cellpadding=0 border=0 width=210 height=100%>
  59. <tr height=190>
  60. <td>&nbsp;
  61. </td>
  62. </tr>
  63. <tr>
  64. <td valign="top">
  65. <form name="testage">
  66. <input type="hidden" name="code" value="0">
  67. </form>
  68. <!-- Présentation -->
  69. <a href="#" onclick="if (VersionNavigateur(3.0,4.0))
  70. img13.src='imgs/fl_b.gif';montre('smenu4');
  71. img14.src='imgs/fl_d.gif';cache('smenu5');
  72. img15.src='imgs/fl_d.gif';cache('smenu6');
  73. img16.src='imgs/fl_d.gif';cache('smenu7');
  74. img12.src='imgs/fl_d.gif';cache('smenu3');
  75. img11.src='imgs/fl_d.gif';cache('smenu2');
  76. img10.src='imgs/fl_d.gif';cache('smenu1');
  77. img20.src='imgs/fl_d.gif';cache('smenu31');">
  78. <ul>
  79. <li class="menu">
  80. <table border=0 cellspacing=0>
  81. <tr>
  82. <td width=22 align=center>
  83. <img name="img13" WIDTH=15
  84.  
  85. HEIGHT=15 border=0 src="imgs/fl_d.gif" onLoad="tempImg=new Image(0,0); tempImg.src='imgs/fl_b.gif'" />
  86. </td>
  87. <td class="titre">
  88. <a href="centre.html"
  89.  
  90. target="centre" onclick="window.open('haut2.html','haut');cache('smenu31')"><b>Présentation</b>
  91. </a>
  92. </td>
  93. </tr>
  94. </table>
  95. </li>
  96. <ul id="smenu4">
  97. <a href="#" onclick="if (VersionNavigateur(3.0,4.0))
  98. img20.src='imgs/fl_b.gif';montre('smenu31');">
  99. <table cellspacing=0 cellpadding=0 border=0>
  100. <tr>
  101. <td width=15>
  102. </td>
  103. <td valign=top width=10>
  104. <img name="img20"
  105.  
  106. WIDTH=10 HEIGHT=10 border=0 src="imgs/fl_d.gif" onLoad="tempImg=new Image(0,0); tempImg.src='imgs/fl_b.gif'"
  107.  
  108. />
  109. </td>
  110. <td class="titre">
  111. <!-- Sousmenu 2 -->
  112. <a href="centre.html"
  113.  
  114. target="centre" onclick="montre('smenu31');">Services municipaux
  115. </a>
  116. <ul id="smenu31">
  117. <!-- Empeche l'affichage de la ligne en selection de la cellule -->
  118. <script
  119.  
  120. language=javascript>
  121.  
  122.  
  123. cache('smenu31');
  124. </script>
  125. <!-- Fin empechement -->
  126. <table cellspacing=0
  127.  
  128. cellpadding=0 border=0>
  129. <tr>
  130. <td
  131.  
  132. class="sstitre">
  133.  
  134.  
  135. <a href="presentation/p_1_1.html" target="centre" onclick="window.open('haut2.html','haut')"><b>- Conseil
  136.  
  137. municipal</b>
  138.  
  139.  
  140. </a>
  141. </td>
  142. </tr>
  143. <tr>
  144. <td
  145.  
  146. class="sstitre">
  147.  
  148.  
  149. <a href="presentation/p_1_3.html" target="centre" onclick="window.open('haut2.html','haut')"><b>- CCAS</b>
  150.  
  151.  
  152. </a>
  153. </td>
  154. </tr>
  155. <tr>
  156. <td
  157.  
  158. class="sstitre">
  159.  
  160.  
  161. <a href="presentation/p_1_4.html" target="centre" onclick="window.open('haut2.html','haut')"><b>-
  162.  
  163. Commissions</b>
  164.  
  165.  
  166. </a>
  167. </td>
  168. </tr>
  169. <tr>
  170. <td
  171.  
  172. class="sstitre">
  173.  
  174.  
  175. <a href="presentation/Cptrenduconseil.htm" target="centre" onclick="window.open('haut2.html','haut')"><b>-
  176.  
  177. Compte-rendu du Conseil Municipal</b>
  178.  
  179.  
  180. </a>
  181. </td>
  182. </tr>
  183. <tr>
  184. <td
  185.  
  186. class="sstitre">
  187.  
  188.  
  189. <a href="presentation/p_1_2.html" target="centre" onclick="window.open('haut2.html','haut')"><b>- Documents
  190.  
  191. administratifs</b><br /><br />
  192.  
  193.  
  194. </a>
  195. </td>
  196. </tr>
  197. </table>
  198. </ul>
  199. <!-- Fin sous menu 2 -->
  200. </td>
  201. </tr>
  202. <tr>
  203. <a href="#" onclick="if
  204.  
  205. (VersionNavigateur(3.0,4.0))
  206. img20.src='imgs/fl_d.gif';cache('smenu31');">
  207. <td width=15>
  208. </td>
  209. <td valign=top width=10
  210.  
  211. class="titre">-
  212. </td>
  213. <td class="titre">
  214. <a
  215.  
  216. href="presentation/Epertiqui.htm" target="centre" onclick="cache('smenu31');">Epertiqui
  217. </td></a>
  218.  
  219. </tr>
  220. <tr>
  221. <td width=15>
  222. </td>
  223. <td valign=top width=10
  224.  
  225. class="titre">-
  226. </td>
  227. <td class="titre">
  228. <a
  229.  
  230. href="appel/a_1.html" target="centre" onclick="cache('smenu31');">Appels d'offre
  231. </a>
  232. </td>
  233. </tr>
  234. <tr>
  235. <td width=15>
  236. </td>
  237. <td valign=top width=10
  238.  
  239. class="titre">-
  240. </td>
  241. <td class="titre">
  242. <a
  243.  
  244. href="presentation/domtps.html" target="centre" onclick="cache('smenu31');">Dompierre au fil du temps
  245. </a>
  246. </td>
  247. </tr>
  248. <tr>
  249. <td width=15>
  250. </td>
  251. <td valign=top width=10
  252.  
  253. class="titre">-
  254. </td>
  255. <td class="titre">
  256. <a
  257.  
  258. href="presentation/p_1_5.html" target="centre" onclick="cache('smenu31');">Dompierre au fil de l'eau
  259. </a>
  260. </td>
  261. </tr>
  262. <tr>
  263. <td width=15>
  264. </td>
  265. <td valign=top width=10
  266.  
  267. class="titre">-
  268. </td>
  269. <td class="titre">
  270. <a
  271.  
  272. href="presentation/wikipedia.html" target="centre" onclick="cache('smenu31');">Informations générales
  273. </a>
  274. </td>
  275. </tr>
  276. <tr>
  277. <td width=15>
  278. </td>
  279. <td valign=top width=10
  280.  
  281. class="titre">-
  282. </td>
  283. <td class="titre">
  284. <a
  285.  
  286. href="presentation/dompierre.html" target="centre" onclick="cache('smenu31');">Association des Dompierre de
  287.  
  288. France
  289. </a>
  290. </td>
  291. </tr>
  292. <!--<tr><td width=15></td><td valign=top width=10><FONT FACE="cordial,garamond,Book Antiqua" SIZE=3
  293.  
  294. COLOR=#ffffff>-</td><td><FONT FACE="cordial,garamond,Book Antiqua" SIZE=3 COLOR=#ffffff><a
  295.  
  296. href="presentation/archactu.html" target="centre" onclick="cache('smenu31');">Actualités
  297.  
  298. passées</a></li></td></tr>-->
  299. </table>
  300. </a>
  301. </ul>
  302. </ul>
  303. </a>
  304. <!-- Economie -->
  305.  
Attached Files
File Type: php menuDW.php (42.4 KB, 2 views)
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: javascript function not working in firefox

 
0
  #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 Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: javascript function not working in firefox

 
0
  #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 Quick reply to this message  
Join Date: Jul 2007
Posts: 2
Reputation: jeremusic is an unknown quantity at this point 
Solved Threads: 0
jeremusic jeremusic is offline Offline
Newbie Poster

Re: javascript function not working in firefox

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

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC