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
2 Answers
Reset to default 4Unfortunately, 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条)