We have a multistep wizard which uses Vf pages. We want to throw an alert message to Users if they click back button on browsers . I know we can do this with JavaScript but I want a browser independant solution. How Would we do this at the controller level ? Any sample code or approach you guys have done would help.
-
3locking back button in browsers is a bad user experience for sure !!!– Mohith ShrivastavaCommented Jul 11, 2013 at 18:34
-
not a perfect solution but prominent 'next' and 'previous' buttons on your wizard can 'encourage' your users to avoid the back button– cropredyCommented Jul 13, 2013 at 0:33
1 Answer
Unfortunately, you can't do this at the controller level. The browser's state is neatly tucked away in the View State, which you have no direct access to at the controller level. As a side note, if you use just one page, and that one page uses reRender (thus, uses only AJAX), the user won't go back a page, but out of the entire wizard (which is better from a stateful point of view), then you can just trap beforeunload and allow the user to cancel losing all of their data.