Reputation: 93
EDIT: Managed to fix it. See answer.
I attached a "beforeunload" event listener to the window in order to change some general styles right before the user leaves the page. However, Firefox interprets this as me wanting to query the user on whether they want to leave so it triggers an alert modal with the "This page is asking you to confirm that you want to..." message.
Is there any way I can prevent this and just let the user leave the page?
I tried using e.preventDefault()
to no avail.
window.addEventListener('beforeunload', (e) => {
e.preventDefault();
document.getElementById("loading-screen").children[0].style.display = "none";
document.getElementById("loading-screen").style.zIndex = "10000000000";
document.getElementById("loading-screen").style.opacity = "1";
});
Upvotes: 0
Views: 673
Reputation: 93
I managed to fix it in the meantime.
Removing e.preventDefault()
did it. I'm not sure why Firefox behaves this way.
Upvotes: 0