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

211
Vistas
using vanilla js how do i make the url update

how do i make the window.location.url update every 30 seconds to the next id found in the array. Right now i have it alerting hello every few seconds but want the url to change instead

    const myIds=['1_aq4jiqb','1_4u0ocu4u'];

for (let i = 0; i < myIds.length; i++) {
window.location.href = 'https://yahoo.com' + myIds[i]+ '/embed/iframe?';

}
setInterval(function(){ alert("Hello"); }, 3000);
<html>


</html>

update to the next Id after 30 seconds?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It's not possible unless you control each of those sites that you're redirecting to.

When you do window.location.href =, an entirely new document is loaded, with (and with only) the JavaScript(s) that new document links to. Anything that happens in your code after a single window.location.href = runs will be effectively ignored, because your old JavaScript does not carry over to the newly-loaded page.

Unless you control each of the sites you're redirecting to, the only way to accomplish this (on your browser only) would be to inject JavaScript code of your own into every site with a userscript.

about 4 years ago · Juan Pablo Isaza Denunciar

0

If I understand what your're asking, just put the code inside a function, and call that at the setInterval.

const myIds=['1_aq4jiqb','1_4u0ocu4u'];

function switchId() {
  for (let i = 0; i < myIds.length; i++) {
    window.location.href = 'https://yahoo.com' + myIds[i]+ '/embed/iframe?';
  }
}

setInterval(function(){ switchId() }, 3000);
<html>


</html>

about 4 years ago · Juan Pablo Isaza Denunciar
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