Disabling the mouse right click : JavaScript
As mention in the title here is code to disable the right click for the mouse in the browser (tested in IE ).
The code is JavaScript ,the code is readable and can be used to handle other mouse events.
just call DisableRightclick() once in your page.
[script language="javascript" ]
var IE;
var NN;
function right(click)
{
if(IE && (event.button==2 || event.button==3))
{
alert("The right click has been disabled here.");
return false;
}
if(NN && (click.which==2 || click.which==3))
{
alert("The right click has been disabled here.");
return false;
}
return false;
}
function DisableRightclick()
{
if(navigator.appName=="Microsoft Internet Explorer")
{
IE=true;
}
if(navigator.appName=="Netscape")
{
NN=true;
}
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
document.onmousedown=right;
document.onmouseup=right;
window.document.layers=right;
}
[/script]