I'm trying to find a way of disabling the default action of the mouse wheel button which is to open the link in a new tab.
Is that possible?
Bind a generic click event handler that specifically checks for middle clicks. Within that event handler, call e.preventDefault():
e.preventDefault()
$("#foo").on('click', function(e) { if( e.which == 2 ) { e.preventDefault(); } });
Note that not all browsers support preventing this default action. For me, it only works in Chrome. Firefox, Opera and IE9 all do not raise the click event with middle mouse click. They do raise mouseup and mousedown.
2.1m questions
2.1m answers
60 comments
57.0k users