René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Detecting right mouse clicks with onContextMenu

The event handler (in this case: right_mouse_click) should return false, because otherwise, the context menu still appears.
<html>
<head>
<script>

function right_mouse_click() {
  alert("Right mouse button clicked");
  return false;
}

function load_ () {
  document.body.oncontextmenu = right_mouse_click;
}
</script>

</head>
<body onLoad='load_()'>

  Click the right mouse button!

</body>
</head>