How to open a URL in a new Tab using JavaScript or jQuery?

Midhuna picture Midhuna · Nov 8, 2013 · Viewed 625k times · Source

How to open a URL in new tab instead of new window programatically?

Answer

FabianCook picture FabianCook · Nov 8, 2013

Use window.open():

var win = window.open('http://stackoverflow.com/', '_blank');
if (win) {
    //Browser has allowed it to be opened
    win.focus();
} else {
    //Browser has blocked it
    alert('Please allow popups for this website');
}

Depending on the browsers implementation this will work

There is nothing you can do to make it open in a window rather than a tab.