Jan 17, 2010

Easiest way to detect which mouse button is clicked?

Just a single line will tell you which mouse (right or left) button
is clicked. "event.button" will return "1" if right mouse button is
clicked .

In the same way,"event.button" will return "2" if left mouse button is clicked .

File : Mouse_Click_JS.html

<html>
<head>
<script type="text/javascript">
function whichButton(event)
{
if (event.button==2)
{
alert("You clicked the right mouse button!");
}
else
{
alert("You clicked the left mouse button!");
}
}
</script>
</head>
<body onmousedown="whichButton(event)">
<p>Click in the document. An alert box will alert which mouse button
you clicked.</p>
</body>
</html>

=========================
Saalram
Publicize yourself ...
http://saalram.com ( Free ! )
=========================

No comments:

Post a Comment

Saalram.com

Saalram
Publicize yourself ...
http://saalram.com

Free !!!


Place your Ad here - Free!!!
just drop us a mail ... saalram.service@gmail.com

Free !!!