How to disable right click on your website using javascript?

Step::1 Login to your cPanel and click on File Manager section

Step::2 Go inside public_html and edit the .html file for which you want to disable the right click option.

Here we taking sample.html for demonstration purpose.

Step::3 Right click over the file and choose the Edit option

Step::4 Enter the code given below under the body tag

<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></s
cript>
<script>
jQuery(document).ready(function(){
  jQuery(function() {
        jQuery(this).bind("contextmenu", function(event) {
            event.preventDefault();
            alert('Right click is disabled on this site!!')
        });
    });
});
</script>
 

</head>
<body>
Here is my code. Right click on me.
</body>
</html>


Step::5 Once you have added the code, click on Save changes button and close the editor.

Now test the file from a new tab in your web browser. You will find that right click has been been successfully disabled.

Visit our Blog for more details. You can also watch the video here.

  • How to disable right click on your website using javascript, how to disable right click on your website, How do I disable right click on my web page, how to disable right click on your web page, How do I disable right click on my website
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Install WordPress in Sub-Directory?

Login to cPanel. Select Softaculous Apps Installer from Software section. Select WordPress...

How to Restore Backups Using JetBackup 4 in cPanel?

Login to cPanel and get inside JetBackups section. Here, you will find multiple features which...

How to Suspend Outgoing Emails of a cPanel Account as WHM Reseller?

To manage the bulk mailing that occurred from a cPanel account hosted within your WHM Reseller,...

How Can You Create/Install WordPress On Sub-Domains?

#1. Create a subdomain of your main domain Log into your cPanel and go to the Subdomains...

How to disallow a particular directory from being crawled by Google?

Login to your cPanel Go inside File Manager Click on public_html Create a robots.txt file....