Disable Right Click II

[Total: 0    Average: 0/5]

This example shows how to really disable the right click.

Head Code:

<script type=text/javascript>
var eventCounter = 0;
var maxEvents = 2; // set this to be the max number of normal alert messages.
var msg = "Right Click Is Disabled";
if(document.layers) window.captureEvents(Event.MOUSEDOWN);

function no_click(e){
if (navigator.appName == 'Netscape' && ( e.which == 2 || e.which == 3))
 {
   if (++eventCounter >= maxEvents)
     prompt(msg,"");
   else
     alert(msg);
   return false; // this works!
 }
 if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
 {
   if (++eventCounter >= maxEvents)
     prompt(msg,"");
   else
     alert(msg);
   event.returnValue=false; // this does not really work... (it should - bug in IE?)
   return false; // this is just here for show - it does nothing in IE.
 }
}
window.onmousedown=no_click;
document.onmousedown=no_click;
</script>

Body Code:

This example shows how to really disable the right click.
As long as the user has javascript enabled, (s)he really can not use the right click on your window.
This only works for IE and NS browsers.
NOTE: There is a way to actually get the menu to appear - clicking the right button while pressing the space bar can get the menu to appear.  Not always - it must be a weird timing issue.  If you find a fix for this [so no one can get the menu to appear] please let us know!
Thanks.

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *