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

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