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

154
Vistas
Javascript refresh page alert returns wrong result

I would like to make an alert, that when someine will refresh the page it will ask him or inform him something.

There are some examples, but in any case it works properly for me.

For instance, for code I've used here:

   window.onbeforeunload = function() {
   return "Data will be lost if you leave the page, are you sure?";
   };  
   $(document).on("submit", "form", function(event){
   window.onbeforeunload = null;
   });

I have constant message, like below:

enter image description here

The same applies to the second code:

 window.addEventListener('beforeunload', (event) => {
   event.returnValue = `Are you sure you want to leave?`;
 });

Is it something I am doing wrong here? I don't understand why the alert message is still thhe same.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Browsers now do not allow the app to specify that string any more. It was used maliciously to jam spam in.

about 4 years ago · Juan Pablo Isaza Denunciar
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