3

I would like to open multiple tab in the main browser: Here is my code:

    function openSM()
    {
        window.open("http://www.google.com","_blank");
        window.open("http://www.yahoo.com","_blank");
        window.open("http://www.bing.com","_blank");
    }
...
<div onClick="openSM()"> This is a div </div>

But only the first window open in new tab, the other windows open in a new browser. What I should do to open every page in the same browser?

2
  • Why do you want to do this? Commented May 1, 2013 at 11:50
  • 1
    Which browser would that be? I'd imagine popup blockers would prevent opening more than one in most browsers. Commented May 1, 2013 at 11:51

2 Answers 2

4

Unfortunately, you have no control over this so you will not be able to force a new tab to open programmatically. It's the browser that controls that feature, which can generally be configured by users.

It could only be forced if you have control over the client's browser configuration and/or can install extensions in the client's browser (often the case in intranets)

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

Comments

2

I had done similar work, but didn't get success using simple javascript on page. So I create an extension and then the same code worked, you need a little modification in that:

    var urls = ["http://www.google.com", "http://www.yahoo.com", "http://www.bing.com"];

    var interval = setInterval(function() {
        var url = urls.pop();
        if(!!url) {
            window.open(url);
        }
        else {
            clearInterval(interval);
        }
    }, 100);

Hope this work for you too.

3 Comments

This is the ONLY solution that should be considered correct
@BenPetersen That solution is just plain wrong. If I configure my browser to open new windows rather than tabs window.open will open a new browser window, not a tab. Like I said, there's nothing you can do about it unless you have control over the client's browser configuration which is not the case on Internet (but could be in Intranets).
It's not because that code opened up new tabs in your browser that this solution works according to the question.

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.