2

我有以下短代码

<body oncontextmenu="return false">
  <p class="info">
   Books are the world of information. As said the books are the best friends. A wise    
     man always has a library of several books</p>
  <ul id="contextmenu">
 ........

JS:

$('.info').mousedown(function (event) {
    if (event.button == 2) {
        $('#contextmenu').show();
    }
}

当我右键单击 .info 时,我希望浏览器的上下文菜单不会与我们的上下文菜单一起默认显示。

oncontextmenu="return false"

不工作

4

1 回答 1

2

将此 javascript 放在您的 head 标记中

    <script>
        document.oncontextmenu = function(e){
         return false;
        }
    </script>

以下也适用于我

<html oncontextmenu="return false">
于 2013-09-02T09:40:54.603 回答