How to Disable Right Click on a Website using Html, Css Or Javascript

E-Collins

  • Administrator
  • Hero Member
  • *****
  • Posts: 10834
Disabling Right Click button on your website helps you protect your content online and also makes it had for anyone to copy and past your articles but the question which led you to this page is to learn how to disable right click button on your website using either HTML Body Tag, CSS or javascript.

Yes is good to protect your content online from those who copy and paste the content you worked and research so had to write without your permission but after reading this article you disable right click button on your website to protect your content online but before then let me tell you few things you need to know before protecting your content online.


Before protecting your content you must be yourself and on your own, what do I mean?

If you don't want others to copy your content you must as well not copy their's and if you don't follow this rules then you are not doing it right.

Now let's get to the main business (how to disable right click)

There few ways you can disable right click button on your website using JavaScript, CSS and HTML body tag and I will be listing them and the method involved to disable right click button on your website, blog starting with HTML Body Tag

=> How to Disable right click button using HTML Body Tag

To disable right button using HTML Body Tag, view the source code of your either newly or old website, and search for <body> and then add the oncontextmenu handler to you website source <body> codes exactly as quoted below.
Quote
<body oncontextmenu=”return false;” >


Now save it and test your work and so how it works

=> How to Disable Right Click Using CSS

Yes it's possible to disable right click button on any website using the CSS of the website, in case you don't know the css file is responsible for the look and design of any website and the good news here is that you can as well use it to secure your website contents just by adding few codes on your website CSS file.

To disable right click on your website using CSS kindly add the following code on your website CSS file and save it and see how greats it works

Quote
.body {
-webkit-user-select: none;  /* Chrome all / Safari all */
-moz-user-select: none;     /* Firefox all */
-ms-user-select: none;      /* IE 10+ */
-o-user-select: none;
user-select: none;
}


=> How To Disable Right Click Using JavaScript


Manry people use this method to protect their online content and if using javascript to protect your content is what you want then it can be done but remember that if a user disables javascript on his or her browser then he can be able to copy your content.

For Wordpress users
There are countless Wordpress plugins that can fulfil your wish within a few clicks, if you are using WordPress you might not need any special code to protect your content online all you need is to search and install a plugin from your Wordpress blog dashboard.

For Bloggers Blog users

If you are using Google's Bloggers then add this code to your Blogger template source code by following this simple steps below.

Now all you need to do is to Login to your blogger account then click and design then Edit HTML to open the source code of your blogger template source codes.

On your computer press ctrl + F to open a search command and then search for <body> and place the code below directly above it

Quote
<script language=JavaScript>
<!--
//Disable right mouse click Script
//By Oscar Frank
//For full source code, visit http://www.oscarmini.com
var message="Function Disabled!";
///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
// -->
</script>


Note:

Remember to backup your blogger template in case you made some mistakes you will be able to restore your template to its original form

Hope this article have helped you disable right click button on your website as you wished.


 

Quick Reply

NName:

Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture: