goku toriyama
goku toriyama

Reputation: 37

oncontextmenu doesn't prevent the browser's context menu from appearing when i right click

i have the following short code

<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();
    }
}

I want the browser’s context menu not to appear as default along with our context menu when i right click on .info.

oncontextmenu="return false"

doesn't work

Upvotes: 2

Views: 3497

Answers (1)

Morne
Morne

Reputation: 1743

Put this javascript in your head tag

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

The following also works for me

<html oncontextmenu="return false">

Upvotes: 3

Related Questions