3
I have a page whose customer is selecting items, after selected I needed to check if the customer will leave the current page because I need to alert him with a message like "Do you want to save your cart before leaving the page?" if saved and continues redirect, if not just redirect. I wanted to do for global Redirects because I could make appear a pop-up asking if he wanted to and then do a window.location.href but I want it to fit for everyone and not do one by one the Redirects... I got a javascript method that does an action before redirecting, but even showing a pop-up it redirects without expecting customer response. I want to know if there’s any way I can intercept the redirect and after his response I’ll let him redirect
The function js
$(window).on("beforeunload", function(){
console.log("Deixando a pagina");
$('#modal-form-call').iziModal('open');
});
but there in the form it does not wait for the answer and already redirects