when we use rediect page, either php header location or javascript document.location.href="" to redirect the user to another page, on the page we redirect the user to, the back button will not work. because it will redirect back to that page again.

how to solve this back button not working problem when redirect page is used?

thanks.

    11 days later

    When I was searching through the site, I found this problem which was posted by "searain". In my code I having the same problem.

    If you have a solution can you share that with me.

    Thanks.

      Maybe I don't get it... but why would you want someone to be able to go back to a page you just redirected them from. Of course it would send them back to the redirected page!

        i think he is talking about so that they can go back past the redirect page. Say they go to siteA then siteB and siteB redirects them to siteC , the user wants to go back to siteA but when they go back to siteB they get back to siteC. lol. thats what u mean right?

          you are right "DoobyWho".

            why not just use a button.

            <input type = "button" onClick="history.go(-2)">";

              8 months later

              I was wrong in my original post.

              If I use the php header("Location: "), the back button will be OK.

              Although the javascript: document.location.href="" may work in the same as the header("Location: "). But it does work funny and differently in many different browsers such as the back button function etc.

              I will use the header("Location: ") to redirect from now on.

              I used to use javascript redirect before to avoid the php header error by using header("Location: "). But now I think use the header("Location: ") will force us to use better programming practice to avoid header already sent error.

                Write a Reply...