is there a way to detect if the user navigates away from the page, this includes all ways of navigating such as typing the address, back button click etc..?
I have searched and found out the window.onbeforeunload function. This might be helpful if I just want to check if the user wants to continue navigating or not. What I actually wanted was something like this:
There is a form where the user can edit his/her details. If there is a change and the user does not saved it and accidentally clicks another link, the program will ask if the user will "save", "discard", or "cancel" these changes. As for the onbeforeunload, it would be the "discard" and "cancel" only. So for my question, Is there a way solve this problem?