我的 IE 原形是:
<script>
 function a(){
  document.getElementById("xxx").style.display=""
  document.getElementById("xxx").setCapture()
}function c(){
  alert("测试")
  document.getElementById("xxx").style.display="none"
  document.getElementById("xxx")..releaseCapture()
}
</script><body oncontextmenu = a()><div id=xxx onclick = c style="display:none width:100px;height:300px">自定义鼠标右键内容</div>
</body>在 IE 下一旦我点出了鼠标右键,然后无论鼠标左键的网页的任何部分,都会 alert("测试") ====这是我希望看到的在 FireFox 如何实现?我是使用的 addEventListener("click",c,true); 结果只有在出现的 自定义右键 上onclick 才会出现 alert("测试") ,其他空白部分就没任何反应了。

解决方案 »

  1.   


    document.oncontextmenu = function(e)
    {
    e.preventDefault();
    document.getElementById("xxx").style.display="";
    if (!document.onmouseup)
    document.onmouseup = c;
    }function c(){
      alert("测试");
      document.getElementById("xxx").style.display="none";
      //document.getElementById("xxx").releaseCapture();
      document.onmouseup=null;
    }
    ff没有setcapture,处理下document的事件吧
      

  2.   

    再补充,原来是因为 网页被套在了其他框架中但即使是这样,setCapture 也做的到啊,用 FF 如何才能模拟到 IE 这个效果呢?
      

  3.   

    parent.PopContextMenu(mousex,mousey)
    类似这样的调用自定义contextmenu最好是在最上层的页面实现,以免被frame边框遮盖住