I´m currently using Sammy.js in my Single Page Application and want to notify the user if he tries to leave a site with changed content.
Is it somehow possible to intercept the back command or any other routing change to display some hint before?
I´m currently using Sammy.js in my Single Page Application and want to notify the user if he tries to leave a site with changed content.
Is it somehow possible to intercept the back command or any other routing change to display some hint before?
Copyright © 2021 Jogjafile Inc.
See my answer here for one way to do what you're looking for. The group I work for actively uses this technique to show a dialog whenever a user tries to navigate away from a page that has been modified but not saved.
Outside of the solution I point out there, you cannot prevent the back button from actually navigating them. If you could do that with JavaScript, that could be easily abused to keep users on a page until they closed the browser.