Right mouse button was clicked or left ?
By admin | June 1, 2008
Sometimes you need to know which mouse button has been clicked you can use it block right click on page and many other things
Syntax:
<html>
<head>
<script type=”text/javascript”>
function nb(event)
{
if (event.button==2)
{
alert(“You clicked the right mouse button!”);
}
else
{
alert(“You clicked the left mouse button!”);
}
}
</script>
</head>
<body onmousedown=”nb(event)”>
Click on the document to know which mouse button was clicked.
</body>
</html>
Check this out by yourself by copying the above code in notepad and save it as .html page
Thanks
krates
Topics: Javascript | Comments Off on Right mouse button was clicked or left ?
Related Links: