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

89
Visualizações
How to wait for an HTML Object element to be fully loaded

In my application built with HTML and jQuery, I am using an Object element to embed a page that is also from my application within another page. For ease of explanation, let's say that I am using an Object element to embed page A into page B.

Here is the situation: When a user clicks a button, the onClick method loads page A into an object element on page B. Then, I remove the header and footer of page A within the Object element (doing this in the onClick method as well). The header and footer are being removed to avoid redundancy, as page B is a part of the same application and thus has the same header and footer.

My issue is that the part of the function that removes the header and footer is not waiting for the object element to fully load page A. Thus, when it tries to remove the elements from the DOM, it cannot find them because they are not fully loaded.

For testing purposes, I have just been setting a timeout to force the second part of the function to wait. But I would like to have it run immediately after the object element is loaded so it appears more seamless. My onClick function looks something like below:

function onClick() {
jQuery('#page_a_object_container').show();
jQuery('#page_a_object').attr('data', '/link/to/page/a');

// I would like the code below to wait to be ran until the object element is fully loaded
let headerAndFooterParent = document.querySelector('#page_a_object').contentDocument.children[0];
headerAndFooterParent.removeChild(headerAndFooterParent.children[1]);
headerAndFooterParent.removeChild(headerAndFooterParent.children[0]);
}

Anyone know of a good approach to take here?

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