0

I'm trying to make a dropdown menu that opens something in a new tab if you middle click. The problem is that middle click doesn't seem to trigger the onclick event.

Edit: I haven't learned JQuery, and I would prefer a method that doesn't require it.

DanielLC
  • 5,801
  • 5
  • 18
  • 16
  • did you use the search function? with jquery: http://stackoverflow.com/questions/1795734/triggering-onclick-event-using-middle-click – cari Jan 11 '15 at 19:57

1 Answers1

0

Check out my example:

http://jsfiddle.net/xbtg7j37/

$(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();
});
KaMZaTa
  • 535
  • 2
  • 9
  • 24