Trap the right mouse clickTag(s): Language
<HTML><HEAD>
<script language="javascript">
function click(e) {
if (navigator.appName == 'Netscape'
&& e.which == 3) {
alert("no right click please")
return false;
}
else {
if (navigator.appName == 'Microsoft Internet Explorer'
&& event.button==2)
alert("no right click please")
return false;
}
return true;
}
document.onmousedown=click
</script>
</HEAD>
<BODY>
No right mouse button here!
</BODY></HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript1.2">
var ns = (document.layers)? true:false;
var ie = (document.all)? true:false;
if (ns) document.captureEvents(Event.MOUSEDOWN || Event.CLICK);
document.onclick = sourcecodeprotect;
document.onmousedown = sourcecodeprotect;
// ***********************************************************
function sourcecodeprotect(e) {
if (ns&&(e.which==3)) return false;
else if (ie&&(window.event.button==2)) alert("Source code protected");
else return true;
}
//***********************************************************
function cleanup() {
if (ns) document.releaseEvents(Event.MOUSEDOWN || Event.CLICK);
}
</SCRIPT>
</HEAD>
<BODY onunload="cleanup()">
No right click here!
</BODY>
Some browsers may support a special parameter in the BODY tag to disable the RMB
<BODY oncontextmenu="return false">
<BODY ondragstart="return false">
<BODY onselectstart="return false">
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com