How to disable the right click, copy text and view source in a website

If you want to secure your website with JavaScript no right click ,no copy text , block the view source in the browser (CTRL + U).

You are worked hardly to place the content in the your site. But some one easily stolen the content just copying from your website or from the view source and some experts may use right  click in your site and stolen the your documents links from your site also.

To Prevent these type of attacks from your website. Copy and paste the following code, and make sure it place in the above </HEAD>  tag.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>  
 <script type="text/JavaScript">  
  var message="NoRightClicking";  
  function defeatIE() {if (document.all) {(message);return false;}}  
  function defeatNS(e) {if   
  (document.layers||(document.getElementById&&!document.all)) {  
  if (e.which==2||e.which==3) {(message);return false;}}}  
  if (document.layers)   
  {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=defeatNS;}  
  else{document.onmouseup=defeatNS;document.oncontextmenu=defeatIE;}  
  document.oncontextmenu=new Function("return false")  
 jQuery(document).ready(function($){  
  $(document).keydown(function(event) {   
  var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();  
  if (event.ctrlKey && (pressedKey == "c" || pressedKey == "u")) {  
  return false;   
  }  
  });  
 });   
 </script> 

Download Demo
* If you like this post please don’t forget to subscribe Techies Badi - programming blog for more useful stuff


EmoticonEmoticon