html - Open multiple tabs in the same browser by JavaScript - Stack Overflow

I would like to open multiple tab in the main browser:Here is my code:function openSM(){window.open(&q

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

    function openSM()
    {
        window.open("","_blank");
        window.open("","_blank");
        window.open("","_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?

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

    function openSM()
    {
        window.open("http://www.google.","_blank");
        window.open("http://www.yahoo.","_blank");
        window.open("http://www.bing.","_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?

Share Improve this question edited Jul 19, 2017 at 10:03 Ripon Al Wasim 37.9k42 gold badges159 silver badges178 bronze badges asked May 1, 2013 at 11:41 Carl MarkCarl Mark 3711 gold badge12 silver badges23 bronze badges 2
  • Why do you want to do this? – DaraJ 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. – JJJ Commented May 1, 2013 at 11:51
Add a ment  | 

2 Answers 2

Reset to default 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)

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.", "http://www.yahoo.", "http://www.bing."];

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

Hope this work for you too.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744904502a4600170.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信