I have been trying to learn is much as I can about events in JavaScript. One of the sites I visited in this pursuit was "developer.mozilla.org". At that site I found the script below which is supposed to generate and an alert box telling you whether you click over the paragraph, included in the HTML, with the right mouse button or the left mouse button or the center mouse button. It only works on the left mouse button on my computer in both Internet Explorer and Firefox so please tell me why. I would appreciate it.


Link to the script I'm talking about

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Mouse which Button</title>
<script type="text/javascript">

function whichButton(e)
  // Handle different event models
  var e = e || window.event;
  var btnCode;

  if ('object' == typeof e){
    btnCode = e.button;

    switch (btnCode){
      case 0  : alert('Left button clicked');
      case 1  : alert('Middle button clicked');
      case 2  : alert('Right button clicked');
      default : alert('Unexpected code: ' + btnCode);


<p onclick="whichButton(event);">Click with mouse...</p>