Pages

Best Solution to Disable Copy/Paste & Right Click on Website

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.

3 comments:

  1. Thanks for share it but sharp shooter will copied by source.

    ReplyDelete
  2. HELLO FRIEND
    have you added this script to your own blog
    if yes then it is not working
    and also i would like to say
    "nothing is imposible"

    ReplyDelete
    Replies
    1. No we have not added it to our blog because it mainly contains tutorials and adding this script will cause problems for them. Let's say you want to copy this script and use it on your site, then how you will do it if we start using it...... Feel free to use it. It works perfectly. We are using it on many other websites.

      Webmaster @ Cellular Pak

      Delete

Donot include personal information like mobile number, email etc.