你的iframe不是已经屏蔽系统右键菜单吗?只要在body里加上事件onmousedown,判断button==2就显示你自己的菜单层,定位使用event.X,event.Y

解决方案 »

  1.   

    谢谢楼上兄弟,我是在iframe加了事件onmousedown,可它不起作用啊!!
    急!!!!!!!!!!!!!
      

  2.   

    <BODY oncontextmenu=yourfunction()>就ok了。这应该是最完整的方案。
      

  3.   

    谢谢大家!!
    我想说得是,大家看问题时,一定要看环境。
    如:<body topmargin="0"  bgcolor="#DAE7EF" leftmargin="0" onConTextMenu="window.event.returnValue=false;">放在单独的页面上就是好的,可我这就不行,如果是下面
    <iframe id=demo name=demo src='1.htm'></iframe>
    <script language=javascript>demo.document.designMode="on";</script>
    <script language=javascript>
    function document.demo.document.oncontextmenu()
    {
       alert("你在 Iframe 里点击了鼠标右键!hehe!");
       return false; //屏蔽系统的右键菜单
    }
    </script>
    也能实现,我就是不明白,我上面的就怎么不行???
      

  4.   

    <html>
    <head>
    </head><body>
     <style>
    <!--
    .skin0 {
    position:absolute;
    text-align:left;
    width:200px;
    border:2px solid black;
    background-color:menu;
    font-family:Verdana;
    line-height:20px;
    cursor:default;
    visibility:hidden;
    }
    .skin1 {
    cursor:default;
    font:menutext;
    position:absolute;
    text-align:left;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    width:120px;
    background-color:menu;
    border:1 solid buttonface;
    visibility:hidden;
    border:2 outset buttonhighlight;
    }
    .menuitems {
    padding-left:15px;
    padding-right:10px;
    }
    -->
    </style>
    <SCRIPT LANGUAGE="JavaScript1.2">
    var menuskin = "skin1";
    var display_url = 0;
    function showmenuie5() {
    var rightedge = document.body.clientWidth-event.clientX;
    var bottomedge = document.body.clientHeight-event.clientY;
    if (rightedge < ie5menu.offsetWidth)
    ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
    else
    ie5menu.style.left = document.body.scrollLeft + event.clientX;
    if (bottomedge < ie5menu.offsetHeight)
    ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
    else
    ie5menu.style.top = document.body.scrollTop + event.clientY;
    ie5menu.style.visibility = "visible";
    return false;
    }
    function hidemenuie5() {
    ie5menu.style.visibility = "hidden";
    }
    function highlightie5() {
    if (event.srcElement.className == "menuitems") {
    event.srcElement.style.backgroundColor = "highlight";
    event.srcElement.style.color = "white";
    if (display_url)
    window.status = event.srcElement.url;
       }
    }
    function lowlightie5() {
    if (event.srcElement.className == "menuitems") {
    event.srcElement.style.backgroundColor = "";
    event.srcElement.style.color = "black";
    window.status = "";
       }
    }
    function jumptoie5() {
    if (event.srcElement.className == "menuitems") {
    if (event.srcElement.getAttribute("target") != null)
    window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
    else
    window.location = event.srcElement.url;
       }
    }
    </script>
    <div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();">
    <div class="menuitems" url="http://">你的连接</div>
    <div class="menuitems" url="http://">你的连接</div></div>
    <script language="JavaScript1.2">
    if (document.all && window.print) {
    ie5menu.className = menuskin;
    document.oncontextmenu = showmenuie5;
    document.body.onclick = hidemenuie5;
    }
    </script></body></html>试试这个
      

  5.   

    http://expert.csdn.net/Expert/topic/1398/1398960.xml?temp=.9664728
      

  6.   

    文件1:
    <OBJECT 
    id=menu1 
    onmouseover="menu1.style.display=''" 
    style=" POSITION: ABSOLUTE;DISPLAY: none; Z-INDEX: 1000;  HEIGHT: 200px" 
    onmouseout="menu1.style.display='none'" 
    type=text/x-scriptlet 
    data=caidan.htm 
    VIEWASTEXT>
    </OBJECT>
    <SCRIPT LANGUAGE=vbscript >
    function document_oncontextmenu()
    document_oncontextmenu=false
    menu1.style.LEFT=window.event.x 
    menu1.style.TOP=window.event.y 
    menu1.style.display=""
    end function
    </SCRIPT>
    文件2:
    caidan.htm 
    <div style='position:absolute;left:0;top:0;width:152;height:200;font:14;color:white;background:black;border:1 solid black'>
    <div onclick="alert(this.innerText)">菜单1</div>
    <div onclick="alert(this.innerText)">菜单2</div>
    <div onclick="alert(this.innerText)">菜单3</div>
    <div onclick="alert(this.innerText)">菜单4</div>
    <div onclick="alert(this.innerText)">菜单5</div>
    <div onclick="alert(this.innerText)">菜单6</div>
    <div onclick="alert(this.innerText)">菜单7</div>
    </div>
    演示:
    www.adr.gov.cn/download/Rmenu.htm
    这个菜单还有个好处,不会被<select>标签遮挡哦!~~
    一般div不会有这个效果