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

143
Visualizações
Javascript onunload not working when idle for a few minutes

I have a web page that calls a post request just before the user tries to exit the page. I am using the window.onbeforeunload event to achieve that. It works when I leave the page a few seconds after I enter the page, but it doesn't when I stay idle for a few minutes. Here's my Javascript:

window.onbeforeunload = function() {
  $.post('http://52.91.227.233:1000/set_day',
    {username: user, useday: day}
  );
};

According to my observation, there's no problem with the post request or the NodeJS app. It is a problem in the onbeforeunload event, though I don't know what exactly the problem is. I've also tried beforeunload but it still doesn't work

Thanks!

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