How to start a new window.open and automatically add Ctrl?

In ff and chrome Ctrl + click on the URL, it will open a new tab and the screen will save the old URL. When I try to use javascript window.open, it will also open a new tab, but the screen will change to a new tab. How to use window.open to open a new tab and save the screen in the old URL?

Or, .. can I use jquery auto add ctrl when I click the URL?

JQuery

$(".link").mousedown(function(e) {
   if (e.which === 1) {
      window.open($(this).attr('href'));
   }
});
+3
source share
2 answers

Ultimately, it comes down to how the browser selects your instructions. JavaScript has no idea whether this is a tab or a new browser window that opens, for example.

-, , , , - , , window.open :

var newWin = window.open($(this).attr('href'));
newWin.blur();
window.focus();
0

return false; , . , return false; .

jQuery

$(document).ready(function(){ $("a").click(function() { var newWin = window.open($(this).attr('href')); newWin.blur(); window.focus(); return false; }); });

, "", .

0

All Articles