You need to hang the function to close the tab / window. Ie, the user pops up the pop-up window before closing the tab and the tab does not close. When you close the popup window - closes the tab. I tried to implement through beforeunload, but the problem is that when closing, a modal window pops up with the question:
"This page asks you to confirm that you want to leave - the data you entered may not be saved."
Is it possible to bypass this message? Is it worth getting around it? Can it somehow be implemented differently?
How implemented now:
$(window).one("beforeunload", function() { openPopup(1000); return "Вы не зарегистрированы!"; });
The openPopup function opens the magnificPopup window.
function openPopup(time){ var mfp = $.magnificPopup.instance; setTimeout(function() { if (!mfp.isOpen) { $.magnificPopup.open({ items: { src: $(".callback") }, type: "inline" }); } }, time); }