Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

264
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda