<BODY onclick = "haha()">
<style type="text/css">
<!--
.t {  filter: Alpha(Opacity=50)}
.up{ background-color: #3A6EA5; border-left: 2 solid #A6C1DF;border-right: 2 solid #002200; border-top: 2 solid #A6C1DF; border-bottom: 2 solid #002200 }
td {  font-size: 12px; line-height: 22px}
a:link {  color: #FFFFFF; text-decoration: none; height: 20px; width: 63px; border-color: #33CCFF #30CCFF #30CCFF; background-color: #0099FF; border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
a:visited {  color: #FFFFFF; text-decoration: none; height: 20px; width: 63px; border-color: #33CCFF #30CCFF #30CCFF; background-color: #0099FF; border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
a:hover {  background-color: #FF66FF; height: 20px; width: 61px; border: #FFFFFF; border-style: dotted; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
-->
</style>
<table border = 1>
<tr><td id = "asd" oncontextmenu="window.event.returnValue=false;show_div(this, 'haha');" >asdf</td></tr>
<tr><td id = "dfgdf" oncontextmenu="window.event.returnValue=false;show_div(this, 'haha');">asdfsd</td></tr>
</table><SCRIPT language=javascript>
function show_div(obj ,str1 )
{
    var str = "";
str += "<div id=Layer2 style='visibility:hidden;position: absolute;' class = up>";
str += "<table width=100% border=0 cellspacing=0 cellpadding=0 height=100%><tr>";
str += "<td align=center valign=top><font color=#FFFFFF >订餐<br>";
str += "<a href=aomen.aspx target=mainFrame>澳门街订餐</a><br>";
str += "<a href=right.aspx target=mainFrame>普通订餐" + str1 + "</a><br>";
str += "<a href=\"#;\">第三项</a><br></font></td></tr></table></div>";
obj.innerHTML += str;
var rightedge=document.body.clientWidth-event.clientX-100;
var bottomedge=document.body.clientHeight-event.clientY-25;
if (rightedge<Layer2.offsetWidth)
Layer2.style.left=document.body.scrollLeft+event.clientX-Layer2.offsetWidth;
else
Layer2.style.left=document.body.scrollLeft+event.clientX;
if (bottomedge<Layer2.offsetHeight)
Layer2.style.top=document.body.scrollTop+event.clientY-Layer2.offsetHeight;
else
{
Layer2.style.top=document.body.scrollTop+event.clientY;
}
Layer2.style.visibility="visible";
return false;
//如果只想出现 menu 的话, 直接用 obj.innerHTML = str; 就行了
}function hidemenuie5(){
Layer2.style.visibility="hidden"
}
document.body.onclick=hidemenuie5
</SCRIPT>
</BODY>

解决方案 »

  1.   

    <BODY onclick = "haha()">
    <style type="text/css">
    <!--
    .t {  filter: Alpha(Opacity=50)}
    .up{ background-color: #3A6EA5; border-left: 2 solid #A6C1DF;border-right: 2 solid #002200; border-top: 2 solid #A6C1DF; border-bottom: 2 solid #002200 }
    td {  font-size: 12px; line-height: 22px}
    a:link {  color: #FFFFFF; text-decoration: none; height: 20px; width: 63px; border-color: #33CCFF #30CCFF #30CCFF; background-color: #0099FF; border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    a:visited {  color: #FFFFFF; text-decoration: none; height: 20px; width: 63px; border-color: #33CCFF #30CCFF #30CCFF; background-color: #0099FF; border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    a:hover {  background-color: #FF66FF; height: 20px; width: 61px; border: #FFFFFF; border-style: dotted; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    -->
    </style>
    <table border = 1>
    <tr><td id = "asd" oncontextmenu="window.event.returnValue=false;show_div(this, 'haha');" >asdf</td></tr>
    <tr><td id = "dfgdf" oncontextmenu="window.event.returnValue=false;show_div(this, 'haha');">asdfsd</td></tr>
    </table><SCRIPT language=javascript>
    function show_div(obj ,str1 )
    {
        if(!document.all.Layer2)  //在这判断一下,如果有Layer2,就不要再生成一次,让它显示出来就行了
    {
    var str = "";
    str += "<div id=Layer2 style='visibility:hidden;position: absolute;' class = up>";
    str += "<table width=100% border=0 cellspacing=0 cellpadding=0 height=100%><tr>";
    str += "<td align=center valign=top><font color=#FFFFFF >订餐<br>";
    str += "<a href=aomen.aspx target=mainFrame>澳门街订餐</a><br>";
    str += "<a href=right.aspx target=mainFrame>普通订餐" + str1 + "</a><br>";
    str += "<a href=\"#;\">第三项</a><br></font></td></tr></table></div>";
    obj.innerHTML += str;
    }
    else
    {
      document.all.Layer2.style.display = "";
        }
    var rightedge=document.body.clientWidth-event.clientX-100;
    var bottomedge=document.body.clientHeight-event.clientY-25;
    if (rightedge<Layer2.offsetWidth)
    document.all.Layer2.style.left=document.body.scrollLeft+event.clientX-Layer2.offsetWidth;
    else
    document.all.Layer2.style.left=document.body.scrollLeft+event.clientX;
    if (bottomedge<Layer2.offsetHeight)
    document.all.Layer2.style.top=document.body.scrollTop+event.clientY-Layer2.offsetHeight;
    else
    {
    document.all.Layer2.style.top=document.body.scrollTop+event.clientY;
    }
    document.all.Layer2.style.visibility="visible";
    return false;
    }function hidemenuie5(){
    document.all.Layer2.style.visibility="hidden"
    }
    document.body.onclick=hidemenuie5
    </SCRIPT>
    </BODY>
      

  2.   

    try:不过你的程序有问题Layer2.style.visibility=(Layer2.style.visibility=="hidden")?"visible":"hidden";
      

  3.   

    <BODY onclick = "haha()">
    <style type="text/css">
    <!--
    .t {  filter: Alpha(Opacity=50)}
    .up{ background-color: #3A6EA5; border-left: 2 solid #A6C1DF;border-right: 2 solid #002200; border-top: 2 solid #A6C1DF; border-bottom: 2 solid #002200 }
    td {  font-size: 12px; line-height: 22px}
    a:link {  color: #FFFFFF; text-decoration: none; height: 20px; width: 63px; border-color: #33CCFF #30CCFF #30CCFF; background-color: #0099FF; border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    a:visited {  color: #FFFFFF; text-decoration: none; height: 20px; width: 63px; border-color: #33CCFF #30CCFF #30CCFF; background-color: #0099FF; border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    a:hover {  background-color: #FF66FF; height: 20px; width: 61px; border: #FFFFFF; border-style: dotted; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    -->
    </style>
    <table border=1>
    <tr><td id="asd" oncontextmenu="window.event.returnValue=false;show_div(this, 'haha');" >asdf</td></tr>
    <tr><td id = "dfgdf" oncontextmenu="window.event.returnValue=false;show_div(this, 'haha');">asdfsd</td></tr>
    </table><SCRIPT language=javascript>
    function show_div(obj ,str1 )
    {
    var str = "";
    str += "<div id=Layer2 style='visibility:hidden;position: absolute;' class = up>";
    str += "<table width=100% border=0 cellspacing=0 cellpadding=0 height=100%><tr>";
    str += "<td align=center valign=top><font color=#FFFFFF >订餐<br>";
    str += "<a href=aomen.aspx target=mainFrame>澳门街订餐</a><br>";
    str += "<a href=right.aspx target=mainFrame>普通订餐" + str1 + "</a><br>";
    str += "<a href=\"#;\">第三项</a><br></font></td></tr></table></div>";
    obj.innerHTML += str;
    var rightedge=document.body.clientWidth-event.clientX-100;
    var bottomedge=document.body.clientHeight-event.clientY-25;
    if (rightedge<Layer2.offsetWidth)
    Layer2.style.left=document.body.scrollLeft+event.clientX-Layer2.offsetWidth;
    else
    Layer2.style.left=document.body.scrollLeft+event.clientX;
    if (bottomedge<Layer2.offsetHeight)
    Layer2.style.top=document.body.scrollTop+event.clientY-Layer2.offsetHeight;
    else
    {
    Layer2.style.top=document.body.scrollTop+event.clientY;
    }
    Layer2.style.visibility="visible";
    return false;
    //如果只想出现 menu 的话, 直接用 obj.innerHTML = str; 就行了
    }function hidemenuie5(){
    Layer2.removeNode(true);
    }
    document.body.onclick=hidemenuie5;
    </SCRIPT>
    </BODY>
      

  4.   

    bencalie(Bencalie) ,你的方法有错误,再右键点击menu,会报错
      

  5.   

    解决了,散分!
    <BODY onclick = "haha()">
    <style type="text/css">
    <!--
    .t {  filter: Alpha(Opacity=50)}
    .up{ background-color: #3A6EA5; border-left: 2 solid #A6C1DF;border-right: 2 solid #002200; border-top: 2 solid #A6C1DF; border-bottom: 2 solid #002200 }
    td {  font-size: 12px; line-height: 22px}
    a:link {  color: #FFFFFF; text-decoration: none; height: 20px; width: 63px; border-color: #33CCFF #30CCFF #30CCFF; background-color: #0099FF; border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    a:visited {  color: #FFFFFF; text-decoration: none; height: 20px; width: 63px; border-color: #33CCFF #30CCFF #30CCFF; background-color: #0099FF; border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    a:hover {  background-color: #FF66FF; height: 20px; width: 61px; border: #FFFFFF; border-style: dotted; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
    -->
    </style>
    <table border = 1>
    <tr><td id = "asd" oncontextmenu="window.event.returnValue=false;show_div(this,'haha');" >asdf</td></tr>
    <tr><td id = "dfgdf" oncontextmenu="window.event.returnValue=false;show_div(this,'hehe');">asdfsd</td></tr>
    </table><SCRIPT language=javascript>
    function show_div(obj ,str1 )
    {
        if(!document.all.Layer2)  //在这判断一下,如果有Layer2,就不要再生成一次,让它显示出来就行了
    {
    var str = "";
    str += "<div id=Layer2 style='visibility:hidden;position: absolute;' class = up>";
    str += "<table width=100% border=0 cellspacing=0 cellpadding=0 height=100%><tr>";
    str += "<td align=center valign=top><font color=#FFFFFF >订餐<br>";
    str += "<a id = href1 href=aomen.aspx target=mainFrame>澳门街订餐</a><br>";
    str += "<a href=right.aspx target=mainFrame>普通订餐" + str1 + "</a><br>";
    str += "<a href=\"#;\">第三项</a><br></font></td></tr></table></div>";
    obj.innerHTML += str;
    }
    else
    {
      document.all.href1.href = str1;
      document.all.Layer2.style.display = "";
        }
    var rightedge=document.body.clientWidth-event.clientX-100;
    var bottomedge=document.body.clientHeight-event.clientY-25;
    if (rightedge<Layer2.offsetWidth)
    document.all.Layer2.style.left=document.body.scrollLeft+event.clientX-Layer2.offsetWidth;
    else
    document.all.Layer2.style.left=document.body.scrollLeft+event.clientX;
    if (bottomedge<Layer2.offsetHeight)
    document.all.Layer2.style.top=document.body.scrollTop+event.clientY-Layer2.offsetHeight;
    else
    {
    document.all.Layer2.style.top=document.body.scrollTop+event.clientY;
    }
    document.all.Layer2.style.visibility="visible";
    return false;
    }function hidemenuie5(){
    document.all.Layer2.style.visibility="hidden"
    }
    document.body.onclick=hidemenuie5
    </SCRIPT>
    </BODY>