CurMenu = document.all(MenuID);
这个改成
CurMenu = document.getElementById(MenuID);
CurMenu.style.offsetTop = 20;
改称
CurMenu.style.top= 20;

解决方案 »

  1.   

    改了,还是不行,我把整个的代码发上来 ,你帮我看看吧 ,非常感谢!
    -------------------------------------------------------------------
    <HTML>
    <HEAD> 
    <TITLE>网页中的下拉菜单</TITLE>
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--
    var IsDroped =false;
    function doMenu(MenuID){
        var CurMenu;
        CurMenu = document.getElementById(MenuID);
        //为避免闪烁,如果下拉菜单已经显示则不重画.
        if(IsDroped==true)
        {
           window.event.cancelBubble = true;
           return false;
        }
        window.event.cancelBubble = true;
        TempMenu = CurMenu;
        //计算下拉菜单的位置
        x = window.event.srcElement.offsetLeft + window.event.srcElement.offsetParent.offsetLeft;
        x2 = x + window.event.srcElement.offsetWidth;
        y = pad.offsetHeight;
        
        CurMenu.style.Top = 20;
        CurMenu.style.Left= 114;
        CurMenu.style.clip = "rect(0 0 0 0)";
        CurMenu.style.display = "block";
        alert("hah");
       //延时2毫秒后再显示菜单,保证ToolbarMenu.offsetHeight有值,避免从主菜单移向下拉菜单时下拉菜单消失. 
        window.setTimeout("showMenu()",2);
        return true;
    }
     
    function showMenu(){
        y2 = y+TempMenu.offsetHeight;
       
        TempMenu.style.clip = "rect(auto auto auto auto)";
        alert("44");
        IsDroped =true;//下拉菜单已经显示
    }
    /*
    function hideMenu(){  //如果在下拉菜单的范围之内移动则不隐藏. <BR><BR>   
        cY = event.clientY document.body.scrollTop;
        if(cY>=y&&cY<y2&&event.clientX>=(x5)&&event.clientX<=x2||
           cY>1&&cY<y&&event.clientX>=(x 5)&&event.clientX<= x2-10)
        { 
             window.event.cancelBubble = true;
             return;
        }
        //隐藏
        TempMenu.style.display = "none";
        window.event.cancelBubble = true;
        IsDroped =false; 

    */
    function showmessage(){
      alert("hah");
    }
    function pad_onmouseover(){
       window.event.srcElement.style.color = 'red';
    }function pad_onmouseout() {
       window.event.srcElement.style.color = 'white';
    }
    function pad_onclick(){
       showmessage();
    }
    //-->
    </SCRIPT>
    </HEAD> 
    <body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>
    <DIV ID='menu' STYLE='position:absolute;background-color:white;width:100%;top:0;left:0;'>
    <DIV ID='pad' STYLE='position:relative;height:20;width:100%;font:bold 11pt 宋体;background-color:#007FFF;color:white;'>
    <A TARGET='_top' TITLE='' ID='pad1'
           LANGUAGE=javascript onmouseout="pad_onmouseout()" onmouseover="pad_onmouseover()" onclick="pad_onclick()">菜单项一</A>
    <SPAN style="color:white"></SPAN>   
    <A TARGET='_top' TITLE='' ID='pad2'
           LANGUAGE=javascript onmouseover="pad_onmouseover();doMenu('idpad2');" onmouseout="pad_onmouseout()">菜单项二</A>
    </DIV>
    </DIV> </BODY> 
    </HTML>