Block User Selection & Right Click on Blog or Any Website

Block User Selection & Right Click on Blog or Any Website

I know many people want to disable people to select and copy text from your website. There could be number of reasons you want to do so.

Content Security is most important as you have done all the hard work to create a unique content, but someone else might be coming and copying your stuff on their website. Even if they give you a backlink by saying Source or Original Content, but still you are loosing some or more traffic which you should be getting instead of other person or website.

Also if you use plugins or put code in Javascript file, it might be blocked by the adblockers. So still you are not getting what you want.

Then here is the trick to really annoy & block the users from copying or even right clicking on your website.

Even advance users will have to spend a little time to figure out and remove the script manually then they will be able to copy content or right click on your website.

Let's not waste your time and come to point!

Here is the script, which you can copy in the head section of your website (I hope you know how to do it)

(Please make a backup of your website, I will not be responsible for any wrong thing happened for any reason in anyway or any time from now and onwards.)

Code:

<style>
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>


<script type="text/javascript">
//<![CDATA[
document.onkeypress = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
//alert('No F-12');
return false;
}
};
document.onmousedown = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
//alert('No F-keys');
return false;
}
};
document.onkeydown = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
//alert('No F-keys');
return false;
}
};

function contentprotector() {
return false;
}
function mousehandler(e) {
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if ((eventbutton === 2) || (eventbutton === 3))
return false;
}
document.oncontextmenu = contentprotector;
document.onmouseup = contentprotector;
var isCtrl = false;
window.onkeyup = function(e)
{
if (e.which === 17)
isCtrl = false;
}

window.onkeydown = function(e)
{
if (e.which === 17)
isCtrl = true;
if (((e.which === 85) || (e.which === 65) || (e.which === 80) || (e.which === 88) || (e.which === 67) || (e.which === 86) || (e.which === 83)) && isCtrl === true)
{
return false;
}
}
isCtrl = false;
document.ondragstart = contentprotector;
//]]>
</script>