New window doesn't open as a tab in Chrome

I am building something ONLY for Chrome.

I want to open multiple tabs with window.open

(which Chrome blocks, but I can live with enabling it). But Chrome opens them as new windows, not tabs!

And for some strange reason, I only found information about the opposite. How can I achieve this?

And if on it, how can I trigger programmatically open tabs without blocking Chrome?

EDIT: I've seen some posts say that this is not possible, and that it is a browser preference. First of all, I have no idea how to set this preference! Second, I've seen people claim to have done it, and who should I believe?

EDIT 2: I found out that Chrome opens new windows and doesn't open tabs because a JavaScript window opens, not user clicks. Does anyone know how I can fake a real click? Since calling the click event is still considered not a user click

+3


source to share


2 answers


If your popup is created by direct user action (not blocked by the popup blocker) and uses the default settings, 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 this is a really bad hack, is creating the popup in user action and then setting the location to the final destination using the popup link later, like this:



<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);

      

+6


source


Chrome Add to Single Window: https://chrome.google.com/webstore/detail/one-window/papnlnnbddhckngcblfljaelgceffobn



Automatically moves new windows and pop-ups as a tab to the main window. Thus, there is no more than one window open.

0


source







All Articles