There are a lot of JavaScript available to disable the right click and text selection on webpage but all of them lack the proper functions and almost all of them shows a annoying message when a user clicks on right mouse button like "Right click disabled' or "Copy/paste disabled".

I also faced a similar situation and after searching on Google, I found that there was no script that matches my requirements. So I have created a simple but very effective JavaScript that will disable the copying of text, images and right mouse button. This JavaScript will also disable the commands like Ctrl+C and Ctrl+V. The text will be replaced by your url if some one will try to copy the content from your site.

This is the code:


<script type="text/javascript">function mousedwn(e) { try { if (event.button == 2||event.button == 3) return false; }  catch (e) { if (e.which == 3) return false; }
} document.oncontextmenu = function() { return false; } document.ondragstart   = function() { return false; } document.onmousedown   = mousedwn; </script>

<script language="JavaScript" type="text/javascript">if (top.location != self.location) top.location.replace(self.location);</script>
<meta http-equiv="imagetoolbar" content="no">
<script type="text/javascript">document.ondragstart = function(){return false;};</script>
<style type="text/css">*:not(input,textarea) {
    -webkit-touch-callout: none;    -webkit-user-select: none;}
  img {    -webkit-touch-callout: none;    -webkit-user-select: none;     } </style>
<script type='text/javascript'>window.addEventListener("keydown",function (e) {    if (e.ctrlKey && (e.which == 65 || e.which == 67 || e.which == 85 || e.which == 80)) {        e.preventDefault();    }})        document.keypress = function(e) {        if (e.ctrlKey && (e.which == 65 || e.which == 67 || e.which == 85 || e.which == 80)) { } return false; };</script>


You can use this on any website that supports JavaScript including WordPress, blogger blogs and so on.

How to use this:
For blogger blogs, go to Layout> Add a gadget> HTML/JavaScript and paste the code shown above. Click on save.

Some of the unique features of this Javascript are:
  • Disable right click on your site without showing annoying message.
  • Disable copying of images.
  • Prevents your users from using the commands like Ctrl+C and Ctrl+V.
  • Very fast and easy to use

Let me know what you think of this JavaScript.