Support » Plugins » Hacks » Detect Browser back-button

  • Resolved otti.steinhauer


    as far as I have got much help on this forum I will aks again my newest question.
    In my new plugin I am programming a form in four steps. After the lat step evrything is finished and the user must not go back to the form. Everything is OK with the back-button on the site, but not with the back button of the browser.
    So first I have to detect when the browser-back button is clicked and in this case either to enable this button or redirect to another page.
    How can I test the Broser-buttons?
    My plugin uses php and javascript.



Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    I’m not sure the browser back button is able to be blocked. You can intercept keystrokes, but I believe browser events are not accessible. Only document events are accessible AFAIK. I could be wrong though, so further research may be warranted.

    In any case, the user can go back through other means, such as browser history, so if preventing going back is important, you should take further measures beyond preventing the back button anyway. You should assume the user can manage to go back regardless of measures you’ve taken, it’s their browser, not yours. The server should record some value associated with the user telling the server to ignore requests for that page again as well as ignoring form POSTs from that page as well.

    I say “ignore” but I really mean respond with an error message of some sort and not fulfill the request 🙂 In short, the solution is not to prevent browser events, but to render them ineffectual server side, where you have complete control.

    Hello bcworkz,
    thank you for your informative an explicit anser. I resolved this problam by using SESSION to store the information wether ths button was already submitted or not. This works fine for me.
    Is there any chance to give you a thank-you gift like a better score?


    Moderator bcworkz


    Hi Ottilie,

    Sorry for the slow response, I’ve been away. I’m pleased you were able to resolve your problem. Being able to help people like yourself pleases me and is all the reward I seek. I appreciate your desire to reward helpful responses, but this forum has no mechanism for scoring responses or rewarding contributors with any kind of ranking. Furthermore, any other, more tangible gifts or rewards outside of this forum are forbidden by the rules here.

    Your gratitude is truly adequate reward for me, thank you 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Detect Browser back-button’ is closed to new replies.