How to Confirm before Leaving Page in Javascript
You can implement a function to be called before the user leaves a page with Javascript as follows:
This is a typically solution for when you want the user to confirm their changes are saved before allowing them to close the current page in editing tools.