$(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').replaceWith(multilink);// ...and replace the original HTML links with the new link.
});
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').replaceWith(multilink);// ...and replace the original HTML links with the new link.
});
RGRodgers
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:
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.
$(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
});