After making changes on a page with a form, I would like to automatically save those changes without requiring any confirmation from the user.
After researching on this question, I modified one of the answers to fit my needs. It's important to note that I am not using the return statement:
function setConfirmUnload(on) {
window.onbeforeunload = (on) ? unloadMessage : null;
}
function unloadMessage() {
alert('Gonna save now');
setTimeout(validate_submit,500);
}
This function is only activated when the user enters information into the form. If any input value is changed, I call
setConfirmUnload(true);
Issue observed in FF23: When the user attempts to navigate away from the page, the alert is displayed, validate_submit() is executed upon clicking "OK", the new page loads - BUT then the alert comes up again and the user is taken back to the original page. Why is this happening? Can anyone explain this behavior?