Documentation and Books

Recent site activity

Web Development‎ > ‎JavaScript‎ > ‎

How to prevent the use of the right mouse button on a page?

You can block the right mouse button in the following way:

  <script language="javascript">
<!--
function click(event) {
if (document.all) {
if (event.button == 2) {
return false;
}
}
if (document.layers) {
if (event.which == 3) {
return false;
}
}
}

if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}

document.onmousedown=click;
//-->
</script>