menu1.style.left再加上(window.screen.width-页面的宽度)/2即可

解决方案 »

  1.   

    <script>
    function in1(id){    
    menu1.style.visibility="visible";
    menu1.style.left=getE(bygl)
    menu1.style.top=getEh(bygl)+20
    }
    function out1(id){    
    menu1.style.visibility="hidden";
    }
    function getE(o){
    a=0
    while(o.tagName!="BODY")
    {
    a+=o.offsetLeft
    o=o.parentElement
    }
    return a
    }
    function getEh(o){
    a=0
    while(o.tagName!="BODY")
    {
    a+=o.offsetTop
    o=o.parentElement
    }
    return a
    }
    </script>
    <body>
    <div id=menu1 style="z-index: 4; visibility: hidden; width: 143; position: absolute;  height: 84" border="1">gggggggggggggg</div>
    <table border="0" width="662" cellspacing="0" cellpadding="0">
    <tr> 
    <td bgcolor="#5C8E4E" height="8" width="58"><img border="0" src="img/wel_2_1.gif" width="58" height="22"></td>
    <TD id=menubar onmouseover="in1(this.childNodes(0).id)" onmouseout=out1(this.childNodes(0).id) align=middle bgcolor="#5C8E4E" width="54" height="8"> 
    <div align="left" id=bygl><FONT color=#ffffff>兵员管理<br></FONT></div>
    </td></tr></table>
      

  2.   

    调用这两函数进行定位
    function getL(e){
    var l=e.offsetLeft;
    while(e=e.offsetParent){
    l+=e.offsetLeft;
    }
    return l
    }
    function getT(e){
    var t=e.offsetTop;
    while(e=e.offsetParent){
    t+=e.offsetTop;
    }
    return t
    }上:getT(obj),左:getL(obj)