8

Can I open a new window but with multiple tabs?

Something like this:

window.open("cnn.com;foxnews.com;nyt.com");
Matt
  • 74,352
  • 26
  • 153
  • 180
David
  • 1,051
  • 5
  • 14
  • 28

4 Answers4

3

There's no concept of tab in standard DOM.

In fact when you ask the browser to open a window it might be a tab, depending on the browser and user settings.

So, apart writing extensions that the user will have to install, no, you can't do that.

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
3

it's Possible open multiple tabs at once the below code is useful

 function openMultipleTabs() {
        var w1 = window.open('http://localhost/sample/first.aspx', '1');
        var w2 = window.open('http://localhost/sample/second.aspx', '2');
        var w3 = window.open('http://localhost/sample/third.aspx', '3');
       }
Ashokreddy
  • 352
  • 1
  • 11
1

No.There is absolutely nothing that a coder can do to open multiple tabs.No for loops can do the job.

The closest I got to a solution was--

Using setInterval with every interval redirecting to some page.But again this cant be occuring at a single instance.

so,the best that you can do is have a window.open("someurl.com") getting opened up in new tab and window.location.href="some_other_url.com"; which will open in the same tab.

DEMO

But,there is nothing that can open multiple tabs at single instance.

HIRA THAKUR
  • 17,189
  • 14
  • 56
  • 87
0

Yes, it's possible to open multiple tabs using window.open if you specify a different windowName when calling var window = window.open(url, windowName, [windowFeatures]);

The docs state that windowName is:

A DOMString specifying the name of the browsing context (window, iframe or tab) into which to load the specified resource; if the name doesn't indicate an existing context, a new window is created and is given the name specified by windowName.

This name can be used as the target for the target attribute of or

elements. The name should not contain whitespace. Keep in mind that this will NOT be used as the window's title.
Cosmin Ababei
  • 7,003
  • 2
  • 20
  • 34