Is there a way detect/catch the browser back button being pressed and in doing so ask them if they are sure about going back?
Building an application and it will soon be converted to an ajax based application and per requirements it’s supposed to reset the application if a user goes ‘back’…
I mainly want this to catch the accidental back button presses as I personally feel that if someone can’t follow the directions that are given to them at the beginning of the application…. I’m not worried about their extra work.
If there isn’t a way to do this is would the best solution be to launch the application in a new window/tab so that there is no history for it to go back to?
you can use
onbeforeunloadto detect back button or accidental page navigations:to replace the current page in browser history you can use
window.location.replace():