DIsable right click in browser using JavaScript

The below javascript code can be used to DISABLE RIGHT CLICK in browser. Save this code as a javascript file (.js) and use in any web page. Then automatically the right click will be disabled in those respecitve pages.
This code is well tested in almost every browser say mozilla, IE, Chrome,.....

File Name: DisableRightClick.js

 
CODE:
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
  if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
  function mischandler(){
      alert("Sorry, Right Click is disabled!!");
   return false;
 }
 document.oncontextmenu = mischandler;

1 comment:

  1. very nice example.. but for some of the browsers javascript may not work... for this we need to use jquery.. with jquery.. this may help you.. http://aspnettutorialonline.blogspot.com/2012/05/disable-right-click-on-browser-using.html

    ReplyDelete