- Prototype - Home
- Prototype - Short Overview
- Prototype - Useful Features
- Prototype - Utility Methods
- Prototype - Element Object
- Prototype - Number Processing
- Prototype - Strings Processing
- Prototype - Array Processing
- Prototype - Hash processing
- Prototype - Basic Object
- Prototype - Templating
- Prototype - Enumerating
- Prototype - Event Handling
- Prototype - Form Management
- Prototype - JSON Support
- Prototype - AJAX Support
- Prototype - Expressing Ranges
- Prototype - Periodical Execution
Prototype - Event isLeftClick() Method
This method determines whether a button-related mouse event was about the "left" (primary, actually) button.
Syntax
Event.isLeftClick(event);
Return Value
Returns true if left button is pressed.
Example
NOTE − Looks like it does not work in MSIE.
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
// 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...." );
}
}
</script>
</head>
<body>
<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.</div>
</body>
</html>
Output
prototype_event_handling.htm
Advertisements