我的web项目中本身有右键菜单的功能,当我选择某一文件夹后,使用右键单击,弹出了项目本身的右键菜单项,
但杯具的是同时弹出了浏览器的右键菜单,并且覆盖了项目本身的右键菜单,
现在我想求解如何使用代码,屏蔽掉浏览器的右键菜单,而保留项目本身的。
请高人帮忙,在线等

解决方案 »

  1.   

    <script language="JavaScript">
    function contextmenu() 
    {
      写上系统上下文菜单键指令
    }
    function rightclick() 
    {
      写上右键点击指令代码
    }
    document.oncontextmenu = contextmenu; 
    document.onmousedown = rightclick; 
    document.onmouseup = rightclick; 
    </script>随别猜测,js目前已经生疏。
      

  2.   

    网上挺多例子的。<HTML> 
    <head>
    <script language='javascript'> 
    var mname=new Array( 
    "首 页", 
    "修 改", 
    "下 载", 
    "删 除", 
    "新 建", 
    "刷 新" 
    ); 
    var murl=new Array( 
    "window.open('http://www.cn5.cn','_blank','');", 
    "alert('修改');", 
    "alert('download');", 
    "alert('delete');", 
    "alert('new');", 
    "alert('refresh');" 
    ); 
    var ph=18,mwidth=50;//每条选项的高度,菜单的总宽度 
    var bgc="#eee",txc="black";//菜单没有选中的背景色和文字色 
    var cbgc="darkblue",ctxc="white";//菜单选中的选项背景色和文字色 
    var mover="this.style.background='"+cbgc+"';this.style.color='"+ctxc+"';" 
    var mout="this.style.background='"+bgc+"';this.style.color='"+txc+"';" document.oncontextmenu=function() 

    mlay.style.display=""; 
    mlay.style.pixelTop=event.clientY; 
    mlay.style.pixelLeft=event.clientX; 
    return false; 

    function showoff() 

    mlay.style.display="none"; 
    } function fresh() 

    mlay.style.background=bgc; 
    mlay.style.color=txc; 
    mlay.style.width=mwidth; 
    mlay.style.height=mname.length*ph; 
    var h="<table width=100% height="+mname.length*ph+"px cellpadding=0 cellspacing=0 border=0>"; 
    var i=0; 
    for(i=0;i<mname.length;i++) 

    h+="<tr align=center height="+ph+" onclick=\""+murl[i]+"\" onMouseover=\""+mover+"\" onMouseout=\""+mout+"\"><td style='font-size:9pt;'>"+mname[i]+"</td></tr>"; 

    h+="</table>"; 
    mlay.innerHTML=h; 

    </script> 
    </head>
    <BODY> 
    <body onClick="showoff();" onload="fresh();"> 
    <div id="mlay" style="position:absolute;display:none;cursor:default;" onClick="return false;"></div> 
    </body> 
    </HTML> 
      

  3.   

    <body   oncontextmenu="event.returnValue=false />
    这个是你要的吗?如果是的赶快把分给我把
      

  4.   

    是不是屏蔽网页自己本身的右键菜单只显示自己写的? 
    不过楼上的基本上都是只支持IE不支持firefox!
    IE的有参数可调!firefox的得自己写个方法禁掉他原来的方法
      

  5.   

    楼主要的是  右键 浏览器无反应么?
      
       <script language="JavaScript">       //禁止右键
            document.oncontextmenu = nocontextmenu;  // for IE5+
           document.onmousedown = norightclick;  // for all others
       </script>
      

  6.   

    <body onClick="showoff();" onload="fresh();" oncontextmenu="return false;"> 这个在firefox可以的
      

  7.   

    用 Ext 可以做到,  比如用树,当右键如例子:
    <script type="text/javascript">
    Ext.onReady(function(){

    var root = new Ext.tree.TreeNode({
    id:"root",
    text:"我是你们的祖先",
    allowDrag:false
    });
    var a1 = new Ext.tree.TreeNode({
    id:"a1",
    text:"龟崽子",
    allowDrag:false
    });
    var a2 = new Ext.tree.TreeNode({
    id:"a2",
    text:"龟儿子"
    });
    var a11 = new Ext.tree.TreeNode({
    id:"a11",
    text:"龟孙子"
    });
    root.appendChild(a1);
    root.appendChild(a2);
    a1.appendChild(a11);

    var tree = new Ext.tree.TreePanel({
    renderTo:Ext.getBody(),
    onlyLeafCheckable:false,
    rootVisible:true,
    autoScroll:true,
    width:250,
    animate:false,
    enableDD:true,
    containerScroll:true,
    lines:true,
    checkModel:'cascade',
    root:root
    });

    tree.on('nodedrop',function(e){
    Ext.Msg.alert("提示信息", "当前【"+e.dropNode.text+"】被放到目录【"+e.target.text+"】下!");
    });

    tree.on('contextmenu', function(node,event){
    event.preventDefault();  //这行是必须的  
    rightClick.showAt(event.getXY());  //取得鼠标点击坐标,展示菜单  
    });

    var rightClick = new Ext.menu.Menu({
    items:[
    {text:'编辑',handler:function(node){
    Ext.Msg.alert("提示信息","编辑["+tree.getSelectedNode().text+"]信息");
    }
    },
    {text:'删除'},
    {text:'菜单3'}
    ]
    });

    });
    </script>
      

  8.   


    <html>
    <head>
    <body>
    <script language="JavaScript">
    <!--
     
    if (window.Event) 
      document.captureEvents(Event.MOUSEUP); 
     
    function nocontextmenu() 
    {
     event.cancelBubble = true
     event.returnValue = false;
     
     return false;
    }
     
    function norightclick(e) 
    {
     if (window.Event) 
     {
      if (e.which == 2 || e.which == 3)
       return false;
     }
     else
      if (event.button == 2 || event.button == 3)
      {
       event.cancelBubble = true
       event.returnValue = false;
       return false;
      }
     
    }
     
    document.oncontextmenu = nocontextmenu;  // for IE5+
    document.onmousedown = norightclick;  // for all others
    //-->
    </script>
    点右键看看啊
    </body>
    </html>
      

  9.   


        if(document.addEventListener){
            document.addEventListener("contextmenu",function(e){
                if(e){
                    e.preventDefault();
                }else if(window.event){
                    return false;
                }
            },true);
        }else if(document.attachEvent){
            document.attachEvent("oncontextmenu",function(){
                return false;
            });
        }
      

  10.   

    body {
    font-family: Helvetica, Arial, sans-serif;
    background-color: #F9FDF2;
    color: #333;
    Windsor:expression(document.body.oncontextmenu=function(){return false;});
    }