JQuery warning when you click the middle mouse button?

Possible duplicate:
JQuery: determine if the middle or right mouse button is pressed, if so, do the following:

How do I show a warning window that says β€œmiddle mouse button pressed” when I click on text or some dom element? I want to be able to distinguish between a middle mouse and a regular right click using jquery / javscript.

I really referenced this: JQuery: determine if the middle or right mouse button is pressed, if so, do the following:

and modified the js fiddle: http://jsfiddle.net/zAGLP/29/

But I'm looking for an alternative to the "live ()" function.

+5
javascript jquery html events
source share
1 answer
$(document).bind('mousedown', function(e) { if( (e.which == 1) ) { alert("left button"); }if( (e.which == 3) ) { alert("right button"); }else if( (e.which == 2) ) { alert("middle button"); } e.preventDefault(); }).bind('contextmenu', function(e){ e.preventDefault(); }); 
+13
source share

All Articles