I want to prevent a user from leaving my site while their file is being uploaded to my server. So I can send an alert message to a user using this javascript...
window.onbeforeunload = function() {
return "Your files are not completely uploaded...";
}
The issue I’m having is that after the file upload is complete I don’t want to prevent user navigation. So essentially I want to have the alert message pop up only when the user is trying to leave the site while their file is uploading. I can console.log(“file upload is complete”) when the file is completely uploaded so I know where I should be stopping this event but I’m not sure what the code should look like. Any help is greatly appreciated.