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

363
Vistas
Custom text for beforeunload alert box in angular

I have been working on a solution where I need to show custom text in beforeunload event. I have seen many questions here, but none of them seems to be working. So for angular is there any way using which we can update the text of the alert box? As I want to show the text in both English and French, depending upon language selection.

The code :

listenerFucntion = (event) => {
  // Cancel the event as stated by the standard.
  event.preventDefault();
  // Chrome requires returnValue to be set.
  event.returnValue = 'You are currently in edit mode. Are you sure you want to refresh the page?';
  
}

addAlertWithListener(){

 window.addEventListener('beforeunload', this.listenerFucntion ,true);
}
removeAlertWithListener() {
  window.removeEventListener('beforeunload', this.listenerFucntion,true);
}

Here as you can see I am trying to change the text but all I am getting is : enter image description here

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

0

Changing the message is no longer supported by the standard, so most (if not all) modern browsers will ignore this.

See the specifications here, particularly the note under point 8:

The message shown to the user is not customizable, but instead determined by the user agent. In particular, the actual value of the returnValue attribute is ignored.

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