How to disable Right Click on your website (Script)

This cross-browser script will allow you to disable right click on your website. It will disable the right click menu from appearing when users right click the mouse on your website. This code can be used to stop website visitors from copying content on your website and will prompt a customize message from the website to visitors who right click pages the script has been implemented on.

how to disable right click on your website

The 6th line of the disable right click script contains a place to add a message. Find var message=”Right click is disabled!”; in the script below and replace Right click is disabled! with the message you wish to send your visitors who right click on your website.

disable right click script

To disable right click on your website copy and paste the code below into your header or body of a single webpage you wish to disable right click on.

<script language=JavaScript>

//Disable right mouse click script

var message="Right click is disabled!";

function clickIE4(){
if (event.button==2){
return false;

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
return false;

if (document.layers){
else if (document.all&&!document.getElementById){

document.oncontextmenu=new Function("alert(message);return false")

// --> 

Sean Doyle

Sean Doyle is a tech author and engineer with over 20 years of experience in cybersecurity, privacy, malware, Google Analytics, online marketing, and other topics. Sean's content has been featured in numerous publications.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.