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

252
Visualizações
Display a loading modal after confirming the onbeforeunload pop-up

I am trying to display a loading modal when the user goes to another page of my site.

Since more than half of the pages are forms, I decided to display the pop-up by default if the user does not save his data. Here is the javascript code :

$("input, textarea, select").bind('change', function() {
    $("button[type='submit']").click(function() {
        window.onbeforeunload = function() {
            return
        }
    })

    window.onbeforeunload = function(evt) {
        var message = '?'
        var e = evt || window.event
        e.returnValue = message
        return message
    }
})

$(document).ready(function() {
    $('form.modal-trigger').submit(function() {
        $('#submit-modal').show()
    })

    window.onbeforeunload = function() {
        $('#submit-modal').show()
    }
})

When the user clicks Cancel, all is well, but when he selects OK my modal is not displayed.

Is there any way to display it after the user selects OK ?

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