Disable Right Click Using jQuery

There are situations when developers don’t want their users to use the mouse’s right-click despite it is not considered a best practice and user-friendly feature.

Disabling the right click on a website can be a great way to ensure that the content is not easily copied or stolen. Unfortunately, some users may find it inconvenient or annoying, and it is important to understand the implications of disabling this functionality.

It is kind of easy to use jQuery to block right-click events on a page.

Here is a simple snippet to do so:

//disable the whole document
return false;
//disable on a specific element only
return false;
//or use .contextmenu();
$("#target").contextmenu(function() {
alert( "contextmenu() called" );
return false;

The contextmenu event is sent to an element when the mouse’s right-button is clicked on it, but before the context menu is displayed.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.