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.

  • 3
    locking back button in browsers is a bad user experience for sure !!! Jul 11 '13 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
    – cropredy
    Jul 13 '13 at 0:33

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.