Issue with javascript navigation disappearing

dreamweaver, html, javascript

Solution

You have 2 different version of `mm_menu.js`. And one of them has a syntax error. Note StackOverflow's syntax highlighting on the 2 snippets below.

http://www.gllblaw.com/mm_menu.js (the good version)

/**
 * mm_menu 20MAR2002 Version 6.0
 * Andy Finnell, March 2002
 * Copyright (c) 2000-2002 Macromedia, Inc.
 *
 * based on menu.js
 * by gary smith, July 1997
 * Copyright (c) 1997-1999 Netscape Communications Corp.
 *
 * Netscape grants you a royalty free license to use or modify this
 * software provided that this copyright notice appears on all copies.
 * This software is provided "AS IS," without a warranty of any kind.
 */
function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh, halgn, valgn, pad, space, to, sx, sy, srel, opq, vert, idt, aw, ah) 
{
   // code here...

http://users.acsol.net/~jhart/mm_menu.js (The bad version)

/**
 * mm_menu 20MAR2002 Version 6.0
 * Andy Finnell, March 2002
 * Copyright (c) 2000-2002 Macromedia, Inc.
 *
/
function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh, halgn, valgn, pad, space, to, sx, sy, srel, opq, vert, idt, aw, ah) 
{
   // code here...

See the problem yet? In the header at the top of the bad version, the comment doesn't properly close. A multiline Javascript comment starts with `/*` and ends with `*/`. However, this header comment is busted, it has no end-comment token. So the entire file is commented out and `Menu` doesn't exist.

Close that comment properly and I bet things will work alright.

And so you know how to be a better developer yourself, here's how I figured this out.

I simply opened the developer tools in Chrome, and look at the JS console. Where, in bright red, I see this:

Which immediately told me of the syntax error, and what file and approximate line the error was on. Looking at the file and then seeing Chromes syntaxing highlighting styling the ENTIRE file like a comment (green), made it pretty obvious what was up.

Problem

I am working on some site changes for a friend (he works at a legal firm) who has a navigation bar on the left side of his website. On hover, these show a submenu. Unfortunately, he tried to take out one of the submenu items and lost all of the functionality of the submenu navigation. Now, instead of showing submenus, it shows nothing but an error. Here's the code before (where its working): ``` <script language="JavaScript"> <!-- function mmLoadMenus() { if (window.mm_menu_0327091831_0) return; window.mm_menu_0327091831_0 = new Menu("root",225,30,"Optima, Verdana, Helvetica Neue, sans-serif",14,"#FFFFFF","#FFFFFF","#7E7D7D","#B3B3B3","left","middle",8,0,250,-5,7,true,false,true,0,true,true); mm_menu_0327091831_0.addMenuItem("HARRY&nbsp;GRIFF,&nbsp;P.C.","location='harry-griff.html'"); mm_menu_0327091831_0.addMenuItem("DOUGLAS&nbsp;E.&nbsp;LARSON,&nbsp;P.C.","location='doug-larson.html'"); mm_menu_0327091831_0.addMenuItem("STEPHEN&nbsp;L.&nbsp;LAICHE,&nbsp;P.C.","location='stephen-laiche.html'"); mm_menu_0327091831_0.addMenuItem("BRAD&nbsp;R.&nbsp;WRIGHT,&nbsp;P.L.L.C.","location='brad-wright.html'"); mm_menu_0327091831_0.hideOnMouseOut=true; mm_menu_0327091831_0.bgColor='#555555'; mm_menu_0327091831_0.menuBorder=1; mm_menu_0327091831_0.menuLiteBgColor='#FFFFFF'; mm_menu_0327091831_0.menuBorderBgColor='#777777'; mm_menu_0327091831_0.writeMenus(); } // mmLoadMenus() //-->​​​​​ </script> ``` Here's the code after: ``` <script language="JavaScript"> <!-- function mmLoadMenus() { if (window.mm_menu_0327091831_0) return; window.mm_menu_0327091831_0 = new Menu("root",225,30,"Optima, Verdana, Helvetica Neue, sans-serif",14,"#FFFFFF","#FFFFFF","#7E7D7D","#B3B3B3","left","middle",8,0,250,-5,7,true,false,true,0,true,true); mm_menu_0327091831_0.addMenuItem("HARRY&nbsp;GRIFF,&nbsp;P.C.","location='harry-griff.html'"); mm_menu_0327091831_0.addMenuItem("DOUGLAS&nbsp;E.&nbsp;LARSON,&nbsp;P.C.","location='doug-larson.html'"); mm_menu_0327091831_0.addMenuItem("STEPHEN&nbsp;L.&nbsp;LAICHE,&nbsp;P.C.","location='stephen-laiche.html'"); mm_menu_0327091831_0.addMenuItem("BRAD&nbsp;R.&nbsp;WRIGHT,&nbsp;P.L.L.C.","location='brad-wright.html'"); mm_menu_0327091831_0.addMenuItem("BRAD&nbsp;R.&nbsp;WRIGHT,&nbsp;P.L.L.C.","location='rob-zentner.html'"); mm_menu_0327091831_0.hideOnMouseOut=true; mm_menu_0327091831_0.bgColor='#555555'; mm_menu_0327091831_0.menuBorder=1; mm_menu_0327091831_0.menuLiteBgColor='#FFFFFF'; mm_menu_0327091831_0.menuBorderBgColor='#777777'; mm_menu_0327091831_0.writeMenus(); } // mmLoadMenus()​​​​ //--> </script> ``` Heres the site that is working: first site (this is working, but is the page that needed a few updates Heres the site that is not working: second site (this is not working, hover over the attorney profiles button) I just pasted the javascript that was changed, because that's where I think the problem is, but I can post more if needed. Thanks for all help!

Original source