Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

621
Visualizações
Open multiple tabs at once with JavaScript

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!

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda