August 20, 2000 - Blocking the Right Mouse Button | WebReference

August 20, 2000 - Blocking the Right Mouse Button

Yehuda Shiran August 20, 2000
Blocking the Right Mouse Button
Tips: August 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Sometimes, you want to block a mouse or a keyboard button. Here is a code that will block the right mouse button:

<SCRIPT language=JavaScript>
<!--
function click() {
if (event.button==2) {
alert(' sorry the right button has been blocked !');
}
}
document.onmousedown=click
// --> 
</SCRIPT>

This tip has been contributed by Mike Bird from London. His e-mail is mike_bird@blueyonder.co.uk.