+91 - 9161069102 support@megaacshost.com

How to disable right click on your website using javascript

How to disable right click on your website using javascript

Today in this post, we will show you how to disable right click on your website via javascript.

Step::1 Log on to your hosting  cPanel and then select  File Manager section

MEGA ACS HOST

Step::2 Next now select public_html and edit the .html file for which you want to disable the right click option.

MEGA ACS HOST

Here we taking sample.html for demonstration purpose.

Step::3 Right click on the file and select the Edit option

MEGA ACS HOST

Step::4 Type below code 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 After added the code, next step select the Save changes button and then close the editor.

MEGA ACS HOST

Now if you wnat test open new tab in your web browser(and check wight click). You will see that right click has been been successfully disabled.

We hope this was helpful to you all.

Leave a Reply

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