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

271
Visualizações
JavaScript wait until content loads in iframe and then load another content

I want to create iframe when page is loaded, load content#1 and wait until it loads in the iframe and then load another content#2 the same iframe, then wait some interval and remove iframe.

Also setTimeout functions will be complex and should return some status variables...

Do I do it proper way?

Sorry, I am not good in JavaScript, what happens if loading of content#1 takes more than 25s. i.e. when iframe is removed.

Any pro example/idea? Thanks!

window.onload = function() {

var iframe = document.createElement('iframe');
iframe.id = "iframeid";
iframe.src = 'data:text/html,' + 'content#1';

document.body.appendChild(iframe);

setTimeout(function(){document.body.removeChild(iframe);},25000);
setTimeout(function(){iframe.src = 'data:text/html,' + 'content#2';},5000);

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