function IsRightButtonClicked(e) // e : mouse event
{
var rightclick = false;
e = e || window.event;
if (e.which)
rightclick = (e.which == 3);
else if (e.button)
rightclick = (e.button == 2);
return rightclick;
}
4 Comments:
I see how the function works, but how do you pass e to the function?
the mouse event 'e' can be found like below:
document.getElementById("myDiv").onmousedown = function(e)
{
if(IsRightButtonClicked(e))
alert("Right Button Down");
}
WARNING:
This function only works with MS-IE, FireFox and Google Chrome know the right button as: 1!
I tested it in IE 6, IE 7, Firefox 2, Firefox 3, Google Chrome, Safari. It works just fine.
Post a Comment