November 23, 2013

How to Disable Mouse Right Click on a Web page using JavaScript

Sometimes web page owners want to protect data such as Text and Images to be copied by others and sometimes it is about the link on the page that must be operate on same page by clicking mouse left button because of these reasons web page owners put a JavaScript code in their web pages to disable mouse Right click.

So if you want to perform same task then just copy paste below code inside your web page's <head> tag.

 <script type="text/JavaScript">  
 var message="Right-click has been Disabled";  
 function clickIE() {  
      if (document.all) {(message);return false;}}  
 function clickNS(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);  
      else{ document.onmouseup=clickNS;  
 document.oncontextmenu=new Function("return false")  

When somebody will come to your web page and will click on page by mouse right button then a message will pop-up "Right Click has been Disabled".



We shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its response or damage to your system. We do not guarantee that the integrity or security of this communication has been maintained or that this communication is free of viruses, interceptions or interferences. Anyone communicating with us by email accepts the risks involved and their consequences. We accept no liability for any damage caused by any virus transmitted by this site.