Example of jquery and JavaScript to disable context menu

Many time it is required to disable context menu on complete web page or on some html elements using JavaScript or jquery. This can be done using following script example very easily.

Disable context menu on complete web page

JavaScript example:

In script block use following code

        document.oncontextmenu = function () {
           return false;

Jquery example:

$(document).bind("contextmenu", returnFalse);

Disable context menu on some element like anchor, input etc.

JavaScript example:

Disable context menu on single input text.

<input type="text" oncontextmenu="return false;" />

Jquery example:

Example to disable context menu on all hyperlinks

$(\'a\').bind("contextmenu", returnFalse);

You can easily use jquery selector to disable context menus on html inputs.