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

365
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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