new window doesn't open as tab in Chrome

前端 未结 2 922
面向向阳花
面向向阳花 2021-01-06 19:49

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

相关标签:
2条回答
  • 2021-01-06 19:55

    Chrome Add on "One Window": https://chrome.google.com/webstore/detail/one-window/papnlnnbddhckngcblfljaelgceffobn

    Automatically moves new Windows and Popups as Tab to the Main-Window. So it is never more than a single Window open.

    0 讨论(0)
  • 2021-01-06 20:22

    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);
    
    0 讨论(0)
提交回复
热议问题