Javascript – new window doesn’t open as tab in Chrome

google-chromejavascripttabs

I'm building something ONLY for Chrome.

I want to open several tabs with window.open
(which Chrome blocks but I can live with enabling it).
But Chrome opens them as new windows instead of tabs!

And for some unclear reason I found only information regarding the opposite.
How can I achive this?

And if at it, how can I invoke programmatic tab openings without Chrome blocking them?

EDIT:
I have seen some posts saying it's not possible and that's it's a browser preference.
First of all, I have no idea how to set that preference!
Secondly, I saw people claiming they did it, so who to believe to?

EDIT 2:
I found out that Chrome opens new windows and not open tabs because it's a JavaScript window opening and not user clicks.
Anyone knows how I can fake a real click?
Because calling the click event still counts as not user clicks

Best Solution

If your popup is created by a direct user action (not blocked by the popup blocker) and using the default options it will open in a new tab. If you create it programmatically, it will open as a new window. There is no way to change this behavior.

What you can do, although it is a really bad hack, is create the popup on a user action and then set the location to the final destination using a reference to the popup later on, like the following:

<a href="javascript:;" id="testAnchor" />
var popup1 = null;

document.getElementById('testAnchor').onclick = function() {
    popup1 = window.open('about:blank', 'popup1');
}

  setTimeout(function() {
       popup1.location = 'LOCATION_ON_THE_SAME_ORIGIN_AS_THE_OPENER';

  }, 5000);