4

I need to open multiple tabs on a single window, new window instance for a single link will not be a problem but when it comes to 20+ (which is my case) then 20+ new windows are really a problem, so I need to find a solution, the code has to run on chrome only in my case I have 35 links stored in an array. I am reading array using a for loop and opening links in new tabs using window.open()
I can use only JavaScript for this. I am developing a customized chrome extension.

I found out that while using window.open() to open multiple links in different tabs of a same window in Google Chrome, it succeeds in opening only first 24 windows and left out the rest.
I need to find out a way to open all the links at once with a single click.

There are some Google Chrome Extensions available which work like this like LinkClump
This Extension successfully open all selected links in different tabs of a same window. I am trying to modify its working to suit mine.

Meanwhile, if anyone can get any solution, he/she is most welcome.

5
  • You should clarify what is the problem you're having. What happens when you open 20 windows? Commented Sep 27, 2011 at 5:01
  • I would not be very happy if website opened 20 windows all of a sudden... Commented Sep 27, 2011 at 7:39
  • @slawekwin This is not for use in a website but a Chrome Extension as stated by the OP. I make use of Chrome's ability to open multiple home tabs when it opens so it's not an alien technique. Commented Sep 27, 2011 at 9:53
  • @Alasdair ah, my bad, overlooked the statement Commented Sep 27, 2011 at 10:30
  • Did either solution work for you? Commented Sep 29, 2011 at 7:49

3 Answers 3

5

I wasn't sure if you wanted the links to be open in a new window or not so I've included both possibilities;

Same Window

var linkArray = []; // your links
for (var i = 0; i < linkArray.length; i++) {
    // will open each link in the current window
    chrome.tabs.create({
        url: linkArray[i]
    });
}

chrome.tabs documentation

New Window

// will open a new window loaded with all your links
chrome.windows.create({
    url: linkArray
});

chrome.windows documentation

Regardless of which approach you use you will need to declare the tabs permission in your extension's manifest.

Sign up to request clarification or add additional context in comments.

Comments

3

You can use target="_blank" attribute of a link for opening the corresponding page in new tab.

2 Comments

Thing is, this isn't a link thing. The OP needs a way to do this within a script. Unless you're talking about some hacky way of opening stuff in a new window by generating a link and programatically clicking on it...which seems like an ass-backward way to do things.
I agree with @cHao, I don't think you realize that this is a Chrome Extension question.
3

Solotion: Use setTimeout! With more and more time values

javascript:
var a=document.location.href;
for (var i=0;i<50;i++){
    setTimeout('window.open(a)',i*200);
}
void(0);

This will clone the current tabs 50 times, even in Chrome! Unfortunately, in new Windows instead of new tabs. Silly Chrome :-)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.