vituxa
asked on
I have to be able to open several new tabs by the click of a button
Hi. I have an internal Content Management System program that I am working on.
I need to be able to open multiple tabs by a click of a button.
Right now i have this:
But that will only open the first URL (https://mycmssite.xyz/page_templates.aspx?page_ID=608)
And it opens it in a new window rather than a new tab. What should I do to open all of these at once in each new tab?
I need to be able to open multiple tabs by a click of a button.
Right now i have this:
function editAll() {
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=608', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=607', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=612', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=606', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=605', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=604', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=603', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=602', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=601', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=600', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=599', '_blank', 'toolbar=0,location=0,menubar=0');
}
But that will only open the first URL (https://mycmssite.xyz/page_templates.aspx?page_ID=608)
And it opens it in a new window rather than a new tab. What should I do to open all of these at once in each new tab?
try like
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=608','_newtab', 'toolbar=0,location=0,menu bar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=608','_newtab', 'toolbar=0,location=0,menu
ASKER
sognoct, can you please use three of my urls on this example? It isn't clear to me.
$(function(){ // On DOM content ready...
var urls = [];
urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=608");
urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=609");
urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=610");
var multilink = $('<a href="#">Click here</a>');// Create a new link...
multilink.click(function() {
for (var url in urls) {
window.open(url);// ...that opens each stored link in its own window when clicked...
}
});
$('.yourlinks').replaceWit h(multilin k);// ...and replace the original HTML links with the new link.
});
var urls = [];
urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=608");
urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=609");
urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=610");
var multilink = $('<a href="#">Click here</a>');// Create a new link...
multilink.click(function()
for (var url in urls) {
window.open(url);// ...that opens each stored link in its own window when clicked...
}
});
$('.yourlinks').replaceWit
});
My code fails the same way when the popup blocker interferes. I happen to run the Google Toolbar and so I have to be logged in and have the popup blocker permitting popups for the page that is launching the new tabs. My application is basically a menu that permits a selected series of tabs to be opened in one click. One such example is as follows:
<br><a href="http://download.microsoft.com/" target="_blank"
onclick="
window.open("http://www.microsoft.com/";);
window.open("https://partner.microsoft.com/US/40096013";);
window.open("http://support.microsoft.com/";);
">
Partners</a>
<br><a href="http://download.microsoft.com/" target="_blank"
onclick="
window.open("http://www.microsoft.com/";);
window.open("https://partner.microsoft.com/US/40096013";);
window.open("http://support.microsoft.com/";);
">
Partners</a>
ASKER
sognoct, it doesn't work. It opens just the last url in the list. Can you please test it, make sure it works and give me a working example?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!!!
ASKER
I am sorry I picked the wrong answer by accident as the best one. I wrote to the administrator about my error. Hopefully they get back to me soon and undo my error so that I can award the points to sognoct for the best answer.
thanks
$(function(){ // On DOM content ready...
var urls = [];
$('.yourlinks a').each(function(){
urls.push(this.href);// Store the URLs from the links...
});
var multilink = $('<a href="#">Click here</a>');// Create a new link...
multilink.click(function()
for (var url in urls) {
window.open(url);// ...that opens each stored link in its own window when clicked...
}
});
$('.yourlinks').replaceWit
});