Copyright ©

Prototype Event isLeftClick() Method

previous next


This method determines whether a button-related mouse event was about the "left" (primary, actually) button.



Return Value :


NOTE: Looks like it does not work in MSIE.

<title>Prototype examples</title>
   <script type="text/javascript" 


// Register event 'click' and associated call back.
Event.observe(document, 'click', respondToClick);
// Callback function to handle the event.
function respondToClick(event) {
  var bool = Event.isLeftClick(event);
  if ( bool ){
    alert("Left button is pressed...." );



   <p id="note"> Click anywhere to see the result.</p>
   <p>This example may not work in IE.</p>

   <p id="para1">This is paragraph 1</p>
   <p id="para2">This is paragraph 2</p>

   <div id="division">
       This is divsion.


To understand it in better way you can Try it yourself.

previous next

Copyright ©