Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
SetTimeout inside for loop Javascript

I want to create a pop window and open a list of URLs in the browser. So when the first page loads in the pop up window, Wait for the page to load then open the next page... Go through the list of urls. To wait for the page to load, I use setTimeout. But I can't seem to make my code work, because of the for loop and the setTimeout. The window skips directlt to the last url in the list. Is there any other way I can make it work? Thank you,

Here's my code:

// exammple of list urls
var my_list = ['https://www.youtube.com/watch?v=77kOn5NZBHw',
  'https://www.youtube.com/watch?v=1IRo21UhvZg',
  'https://www.youtube.com/watch?v=yRJxz0NicgI'
]

// open a new pop up window
var response = window.open(my_list[0], 'new', true);

for (let i = 0; i < my_list.length; i++) {
    setTimeout(function() {
    console.log(response.location.href);
    response.location = my_list[i];
  }, 3000)

};
about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda