Last updated on November 28th, 2022 at 07:17 pm

Disable right click using javascript. Tired of searching and integrating so many complex scripts on your webpage just to disable the right click option?

Then here is a simple method inside the HTML or whatever page you want this to happen just add this oncontextmenu=”return false;” attribute along with the HTML tag not BODY tag as shown below

If you would like to alert some message, add customization or call some functions when user right click, check this tutorial.

In your website code, inside the body tag just replace the regular <html> with the code below

<html oncontextmenu="return false">

Add this code if you would like to have some custom alert messages included

<html oncontextmenu="alert('No Right Click Please');return false">

Tested in Mozilla FireFox, Google Chrome and Safari

It used to work with the oncontextmenu option inside body tag but not anymore. So use the above code within html tag.

<body oncontextmenu="return false;"> (NOT WORKING)

Demo (Try right click on the demo page and it will be disabled)

Leave a Reply

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