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

142
Visualizações
onunload and pagehide event not firing after refresh

I have a 2 page application, where one is a parent page which opens the second page using window.open(url). I am watching for onunload or pagehide event from the child page. Both events are fired for the first time when child page opens(as expected) then when I refresh the child page the events are fired again but after that on close or refresh none of the events are triggered. Here is a sample code:

parent page

const newWindow = window.open(url);
newWindow.onunload = () => console.log('Unload event fired');
newWindow.onpagehide = () => console.log('PageHide event fired');

Both onunload & onpagehide events are recorded till first refresh of the child page. After refresh, If I try to refresh the page again or close the tab none of the event is recorded.

Here I am refreshing the child page which window.open opens. Also the url domain for both parent and child are same.

Am I doing something wrong 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