你说的范围太大了,用oncontextmenu事件和弹出菜单吧window.createPopup();

解决方案 »

  1.   

    ky99xing(kk):我有一棵树就是要实现当右键点击根节点时弹出右键菜单,你有现成的弹出右键菜单的例子吗?
      

  2.   

    有啊,不过连的是domino数据库的
      

  3.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>简单的例子:</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="JavaScript">
    var mouseRightPopupMenu = window.createPopup();
    var mouseRightPopupMenuBody = mouseRightPopupMenu.document.body;
    function ShowPopupMenu()
    {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    mouseRightPopupMenuBody.innerHTML = "这里是菜单项";
    mouseRightPopupMenu.show(window.event.x + document.body.scrollLeft, 
    window.event.y + document.body.scrollTop, 
    100, 30, 
    document.body);
    }
    </script>
    </head><body>
    <table border="1" cellspacing="0" cellpadding="3">
      <tr>
        <td oncontextmenu="ShowPopupMenu();">这里点鼠标右键</td>
      </tr>
    </table>
    </body>
    </html>
      

  4.   

    参考一下吧:
    document.write('<DIV ID="tips_table" style="Z-INDEX: 2;POSITION:absolute; VISIBILITY: hidden; WIDTH: 100; TOP: 260; HEIGHT: 84; left:10"></DIV>');
    Xoffset=0;
    Yoffset= 18;
    var IsModify=0;
    var yyy=-2000;xxx=-2000;
    var skn=tips_table.style;
    document.onmousemove=get_mouse;
    document.onclick=HiddenTip;
    document.oncontextmenu=stop;
    var licons = {
    'target'  : '',  
    'icon_e'  : 'icons/0.gif', 
    'icon_l'  : 'icons/90.gif',
    'icon_2'  : 'icons/91.gif',
    'icon_3'  : 'icons/92.gif',
    'icon_18' : 'icons/93.gif',
    'icon_19' : 'icons/94.gif',
    'icon_26' : 'icons/95.gif',
    'icon_27' : 'icons/96.gif' 
    };var a_safemode = true;var trees = [];     function RClick(FolderID)
         {
           if(event.button==2)
    {
      var TabHead='<table width="100" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="#FFFFFF">';
      var mnuAddNew='<tr><td id="mnuaddnew" bgcolor="#A0B4DA" height="20" onMouseOut="mnuaddnew.style.backgroundColor=&quot;#A0B4DA&quot;;" onMouseOver="mnuaddnew.style.backgroundColor=&quot;#000000&quot;;" width="100"><img src="/inside/images/index_image/left_dot.gif" width="20" height="16" align="absbottom"><a href="javascript:MM_goToURL(&quot;parent&quot;,&quot;add_tree.asp?id='+FolderID+'&optiontype=add&quot;)" style="text-decoration: none"><font color="#FFFFFF" style="font-size: 9pt">新建目录</font></a><font color="#FFFFFF"></font></td></tr>';
      var mnuModify='<tr><td id="mnumodify" bgcolor="#A0B4DA" height="20" onMouseOut="mnumodify.style.backgroundColor=&quot;#A0B4DA&quot;;" onMouseOver="mnumodify.style.backgroundColor=&quot;#000000&quot;;" width="100"><img src="/inside/images/index_image/left_dot.gif" width="20" height="16" align="absbottom"><a href="javascript:MM_goToURL(&quot;parent&quot;,&quot;edit_tree.asp?id='+FolderID+'&optiontype=edit&quot;)" style="text-decoration: none"><font style="font-size: 9pt" color="#FFFFFF">修改目录</font></a></td></tr>';
      var mnuDelete='<tr><td id="mnudelete" bgcolor="#A0B4DA" height="20" onMouseOut="mnudelete.style.backgroundColor=&quot;#A0B4DA&quot;;" onMouseOver="mnudelete.style.backgroundColor=&quot;#000000&quot;;" width="100"><img src="/inside/images/index_image/left_dot.gif" width="20" height="16" align="absbottom"><a href="javascript:DeleteCustom(&quot;'+FolderID+'&quot;)" style="text-decoration: none"><font style="font-size: 9pt" color="#FFFFFF">删除目录</font></a></td></tr>';
      var mnuEnd='</table>'
      skn.left =xxx;
      skn.top =yyy;
      if(FolderID=="")
      {
        tips_table.innerHTML=TabHead+mnuAddNew+mnuEnd;
      } 
      else
      {
        tips_table.innerHTML=TabHead+mnuAddNew+mnuModify+mnuDelete+mnuEnd;
      }
      skn.visibility="visible";
          }
         }function DHTMLSupported () {
    try {
    var tmp = "";
    tmp = document.body.innerHTML;
    if (tmp.length <= 0) return false;
    } catch(e) {
    return false;
    }
    return true;
    }