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

258
Visualizações
Can I use onbeforeunload as an event for a script?

So i wanted to make a small game in javascript to be seen in the browser which includes a database, an user would connect and before he leaves the page would forward the progress of his account on said database.

I visited this question : window.onunload is not working properly in Chrome browser. Can any one help me?

And this one : what can i put in beforeUnload?

Which provided information on unload not being as good as onbeforeunload, returning a string rather than an alert.

I have problems with onunload/onbeforeunload events (before making links with the database i tried just having an alert/returning a string to have a message from the browser : seeing an output from event) which don't seem to work on chrome/safari.

For instance this code only trigger a response on my code editor (Komodo) but no browsers :

window.onbeforeunload = function(){return "Are you sure you want to leave this page?";}

So in the end should i just try with the database to see if i can have a script working in onbeforeunload ?

If anyone has an idea/a solution I would enjoy it very much :)

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