Navigation:    Home arrow Disable Right Click
Javascript Disable Right Click PDF  
Digg Reddit Ma.gnolia Stumble Upon Facebook Twitter Google Yahoo! MyWeb Furl" BlinkList Technorati Mixx Bookmark

If you have quality content on your webpage and want to prevent people stealing your resources, you can add this script to disable the right-mouse click. This does not assure complete safety for your resources (there is always a way to copy them), but it is better than nothing. :)

Click here to see a demo page.

Note1:The following script works for IE6 and Netscape.

Note2:Right click cannot be disabled for Opera browsers!

The Javascript function that is listed below. To use it paste the code into the section of your page

  <script>
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape")
document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
</script>

If you found this tutorial useful you might be interested to read the following:

Javascript Text Box Characters Counter

Javascript Create and Resize Popup Windows

Javascript Wait While loading Page Image Display