javascript导航问题消失了

时间:2012-09-29 00:15:07

标签: javascript html dreamweaver

我正在为一位朋友(他在一家律师事务所工作)进行一些网站更改,他的网站左侧有一个导航栏。在悬停时,这些显示子菜单。不幸的是,他试图取出其中一个子菜单项并丢失了子菜单导航的所有功能。现在,它不是显示子菜单,而是显示错误。

这是之前的代码(工作地点):

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

以下是代码:

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

继承人正在运作的网站:

first site (this is working, but is the page that needed a few updates

继承人无效的网站:

second site (this is not working, hover over the attorney profiles button)

我刚粘贴了已更改的javascript,因为我觉得问题出在那里,但如果需要,我可以发布更多内容。

感谢您的帮助!

1 个答案:

答案 0 :(得分:12)

您有2个不同版本的mm_menu.js。其中一个有语法错误。请注意StackOverflow的语法在下面的2个片段中突出显示。

http://www.gllblaw.com/mm_menu.js(好的版本)

/**
 * 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(糟糕的版本)

/**
 * 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...

看到问题了吗?在错误版本顶部的标题中,注释未正确关闭。多行Javascript评论以/*开头,以*/结尾。但是,此标题注释已被破坏,它没有结束注释标记。因此整个文件被注释掉,Menu不存在。

正确关闭该评论,我敢打赌,事情会顺利进行。


所以你知道如何成为一个更好的开发者,这就是我如何解决这个问题。

我只是在Chrome中打开了开发人员工具,然后查看JS控制台。在明亮的红色中,我看到了这一点:

JS console

它立即告诉我语法错误,以及错误所在的文件和近似行。查看该文件,然后看到Chromes语法突出显示样式的整个文件,如注释(绿色),使得它非常明显是什么。