I have the popup appearing but the page continues to unload.
How can I prevent the page from unloading until either the .js-close
is clicked or the form in my popup is submitted?
$(document).ready(() => {
window.onbeforeunload = () => {
const newsSubscribePopup = $('#news-subscribe-popup');
if (newsSubscribePopup.length) {
$.magnificPopup.open({
items: {
src: newsSubscribePopup,
},
type: 'inline',
preloader: true,
modal: true,
showCloseBtn: false,
});
}
};
});`