I am trying to open a few tabs at once from my shopping cart page using Javascript. I have looked at a few similar questions and I already know that you can use several window.open(url) but I'm not really looking forward to that... I currently have this code
function buyAll()
{
$.ajax({
url:'Basket',
type:'POST',
data: { listOfWines : $.toJSON(chosenIds), action : 'buyAll' },
success : function(responseText)
{
for (var i = 0; i < allSliders.length; i++)
{
var cellsCollection = document.getElementById(allSliders[i].id).closest('tr').children;
var row = document.getElementById(allSliders[i].id).closest('tr');
$(cellsCollection)
.animate({ padding: 0 }, 800)
.wrapInner('<div />')
.children()
.slideUp(function() { $(row).remove(); });
}
showSnackOpened();
}
});
for(i = 0; i < allSliders.length; i++)
{
var url = allSliders[i].getAttribute('data-redir');
window.open(url, '_blank');
}
}
Forgive me if the code isn't the best or there's a bit of a mix with the jQuery (JS isn't my best-known language) I take an array of elements on the shopping cart and get a particular attribute of these elements, which is the URL I need to redirect the user to. Once I have the list of URLs I try to iterate over them and open the new tabs. However, the browser obviously blocks the pages from the second onward.
Also, Chrome's tabs API won't be of any use to this project, since not all of the users will be using Chrome.
Any help is much appreciated!