//接上
function mbody_click(){if (misShow){
        srcel = getReal(window.event.srcElement, "className", "coolButton");
        for(var x=0;x<=mmenus.length;x++){
                if(srcel.id=="mMenu"+x)
                return;
        }
        mallhide();
}
}
document.onclick=mbody_click;
function mwritetodocument(){
      var mwb=1;
                     var stringx='<div id="mposflag" style="position:absolute;"></div><table  id=mmenutable border=0 cellpadding=3 cellspacing=2 width='+mmenuwidth+' height='+mmenuheight+' bgcolor='+mmenucolor+
                     ' onselectstart="event.returnValue=false"'+
                     ' style="cursor:'+mcursor+';'+mfonts+
                     ' border-left: '+mwb+'px solid '+mmenuoutbordercolor+';'+
                     ' border-right: '+mwb+'px solid '+mmenuinbordercolor+'; '+
                     'border-top: '+mwb+'px solid '+mmenuoutbordercolor+'; '+
                     'border-bottom: '+mwb+'px solid '+mmenuinbordercolor+'; padding:0px"><tr>'
                     for(var x=0;x<mmenus.length;x++){
                             var thismenu=mmenus[x];
                             var imgsize="";
                             if(thismenu.sizex!="0"||thismenu.sizey!="0")imgsize=" width="+thismenu.sizex+" height="+thismenu.sizey;
                             var ifspace="";
                             if(thismenu.caption!="")ifspace="&nbsp;";
                             stringx += "<td nowrap class=coolButton id=mMenu"+x+" style='border: "+mitemedge+"px solid "+mmenucolor+
                             "' width="+mmenuunitwidth+"px onmouseover=mmenu_over(mmenudiv"+x+
                             ","+x+") onmouseout=mmenu_out("+x+
                             ") onmousedown=mmenu_down(mmenudiv"+x+","+x+")";
                                   if(thismenu.command!=""){
                                       stringx += " onmouseup=mmenu_up();mexec2("+x+");";
                                   }else{
                                             stringx += " onmouseup=mmenu_up()";
                                   }
                                   if(thismenu.pos=="0"){
                                       stringx += " align=center><img align=absmiddle src='"+thismenu.img+"'"+imgsize+">"+ifspace+thismenu.caption+"</td>";
                                   }else if(thismenu.pos=="1"){
                                       stringx += " align=center>"+thismenu.caption+ifspace+"<img align=absmiddle src='"+thismenu.img+"'"+imgsize+"></td>";
                                   }else if(thismenu.pos=="2"){
                                       stringx += " align=center background='"+thismenu.img+"'>&nbsp;"+thismenu.caption+"&nbsp;</td>";
                                   }else{
                                       stringx += " align=center>&nbsp;"+thismenu.caption+"&nbsp;</td>";
                                   }
                             stringx += "";
                     }
                     stringx+="<td width=*>&nbsp;</td></tr></table>";
                     for(var x=0;x<mmenus.length;x++){
                             thismenu=mmenus[x];
                        if(x<0){
                        stringx+='<div id=mmenudiv'+x+' style="visiable:none"></div>';
                        }else{
                        stringx+='<div id=mmenudiv'+x+
                        ' style="cursor:'+mcursor+';position:absolute;'+
                        'width:'+mmenuitemwidth+'px; z-index:'+(x+100);
                        if(mmenuinbordercolor!=mmenuoutbordercolor&&msubedge=="0"){
                        stringx+=';border-left: 1px solid '+mmidoutcolor+
                        ';border-top: 1px solid '+mmidoutcolor;}
                        stringx+=';border-right: 1px solid '+mmenuinbordercolor+
                        ';border-bottom: 1px solid '+mmenuinbordercolor+';visibility:hidden" onselectstart="event.returnValue=false">\n'+
                             '<table  width="100%" border="0" height="100%" align="center" cellpadding="0" cellspacing="2" '+
                             'style="'+mfonts+' border-left: 1px solid '+mmenuoutbordercolor;
                        if(mmenuinbordercolor!=mmenuoutbordercolor&&msubedge=="0"){
                             stringx+=';border-right: 1px solid '+mmidincolor+
                             ';border-bottom: 1px solid '+mmidincolor;}
                             stringx+=';border-top: 1px solid '+mmenuoutbordercolor+
                             ';padding: 4px" bgcolor='+mmenucolor+'>\n'
                             for(var i=0;i<thismenu.items.length;i++){
                                     var thismenuitem=thismenu.items[i];
                                     var imgsize="";
                                     if(thismenuitem.sizex!="0"||thismenuitem.sizey!="0")imgsize=" width="+thismenuitem.sizex+" height="+thismenuitem.sizey;
                                     var ifspace="";
                                     if(thismenu.caption!="")ifspace="&nbsp;";
                                     if(!thismenuitem.isline){
                                     stringx += "<tr><td class=coolButton style='border: "+mitemedge+"px solid "+mmenucolor+
                                     "' width=100% height=15px onmouseover=\"mmenuitem_over("+x+","+i+
                                     ");\" onmouseout=mmenuitem_out() onmousedown=mmenuitem_down() onmouseup=";
                                 stringx += "mmenuitem_up();mexec("+x+","+i+"); ";
                                 if(thismenuitem.pos=="0"){
                                         stringx += "><img align=absmiddle src='"+thismenuitem.img+"'"+imgsize+">"+ifspace+thismenuitem.caption+"</td></tr>";
                                       }else if(thismenuitem.pos=="1"){
                                         stringx += ">"+thismenuitem.caption+ifspace+"<img align=absmiddle src='"+thismenuitem.img+"'"+imgsize+"></td></tr>";
                                       }else if(thismenuitem.pos=="2"){
                                         stringx += "background='"+thismenuitem.img+"'>"+thismenuitem.caption+"</td></tr>";
                                       }else{
                                         stringx += ">"+thismenuitem.caption+"</td></tr>";
                                       }
                                 }else{
                                     stringx+='<tr><td height="1" background="hr.gif" onmousemove="clearTimeout(mpopTimer);"><img height="1" width="1" src="none.gif" border="0"></td></tr>\n';
                                     }
                             }stringx+='</table>\n</div>'
                             }                }                     document.write("<div align='left'>"+stringx+"</div>");
}
mpmenu1=new mMenu('业务管理','','self','','','','');
mpmenu1.addItem(new mMenuItem('药品字典定义','','self',false,'','','','',''));
mpmenu1.addItem(new mMenuItem('医生定义','','self',false,'','','','',''));
mpmenu2=new mMenu('库存管理','','self','','','','');
mpmenu2.addItem(new mMenuItem('药品调价','','self',false,'','','','',''));
mpmenu2.addItem(new mMenuItem('药品盘点','','self',false,'','','','',''));mwritetodocument();

解决方案 »

  1.   

    你这是用菜单梦工场之类自动生成的js文件吧。可以把这些js代码都写到一个php文件中,然后在
    mpmenu1=new mMenu('业务管理','','self','','','','');
    mpmenu1.addItem(new mMenuItem('药品字典定义','','self',false,'','','','',''));
    mpmenu1.addItem(new mMenuItem('医生定义','','self',false,'','','','',''));
    mpmenu2=new mMenu('库存管理','','self','','','','');
    mpmenu2.addItem(new mMenuItem('药品调价','','self',false,'','','','',''));
    mpmenu2.addItem(new mMenuItem('药品盘点','','self',false,'','','','',''));
    部分判断权限
    <?
    if 有权限 {?>
    mpmenu1=new mMenu('业务管理','','self','','','','');
    mpmenu1.addItem(new mMenuItem('药品字典定义','','self',false,'','','','',''));
    mpmenu1.addItem(new mMenuItem('医生定义','','self',false,'','','','',''));
    <?}?>
    可以一个个判断,有的就显示,没有的就不显示不就可以了mpmenu1=new mMenu('业务管理','','self','','','','');式菜单的列名不用判断了可以都显示,只对菜单项mpmenu1.addItem(new mMenuItem('药品字典定义','','self',false,'','','','',''));进行判断就可以了
      

  2.   

    to:: zzh26(瞌睡) 
    如果能写成一个函数的话最好了。php和js结合应用还需要在请教了!
    请执教怎么把js代码写成php文件
      

  3.   

    写成php很简单,PHP文件除了<??>之间的部分PHP会解释执行以外,其它的部分就和HTML一样写你只要把你想控制的部分用PHP的判断语句框起来控制它是不是在客户端生成就行了,可以先把这个js文件改名为php文件,在文件头加上<script language="javascript">在结尾加上</script>另外向我上面所说的加上你自己的php判断语句,调用的时候把这个php文件require到原来调用js的地方就可以了。mpmenu1=new mMenu('业务管理','','self','','','','');表示大的菜单项mpmenu1.addItem(new mMenuItem('药品字典定义','','self',false,'','','','',''));表示菜单的细项。这个js写得很好了,没必要用php写函数,你写好以后同样可以在每一个页面调用它
      

  4.   

    调用的时候
    <html>
    <head>
    </head>
    <body topmargin="0" leftmargin="0" bgcolor="#FFFFCC">
    <script language="javascript">
    //////document.write("<script language=\"javascript\" src=\"menu.js\"><\/script>");
    把这里改成
    <?require "menu.php";?>
    </script>
    </body>
    </html>
      

  5.   

    up
    ------------------------------------ 大家帮回答一下这个问题:
    http://expert.csdn.net/Expert/topic/2489/2489499.xml?temp=.3179743