[jQuery] How to open a new window using middle button?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
5 views
There is a famous code for opening links in a new window:

$(function() {
$('.A _blank').click(function() {
window.open(this.href);
return false;
});
});


Question: how to do the same, only the middle button of the mouse?

PS the Question is "how" and "why".
P. S. S. use mouseup, mousedown is not desirable.
by | 5 views

2 Answers

0 like 0 dislike
$(function() { $('.A _blank').click(function() { if(event.button == 1) window.open(this.href); return false; }); }); 
by
0 like 0 dislike
Tried in Chrome and FF under Linux. In both cases, the middle button, the link opens in a new window.
by

Related questions

110,608 questions
257,186 answers
0 comments
28,009 users