当我右键单击时,oncontextmenu不会阻止浏览器的上下文菜单出现

时间:2013-09-02 09:34:57

标签: jquery html

我有以下短代码

<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"

不起作用

1 个答案:

答案 0 :(得分:2)

将此javascript放入您的头标记

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

以下内容也适用于我

<html oncontextmenu="return false">