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

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

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 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