Search code examples
htmlhttp-redirectbrowser-history

Stop page from appearing in browser history


I have a simple flow:

A.html -> B.html -> C.html

Now, page B either 302's (temporarily redirects giving 302 redirect code) to page C, or it shows a progress bar; then, after an ajax call is done, it redirects to page C. When the user is on C, and they hit "Back" I want them to end up on A instead of B.

If the page did the 302 redirect, then the back behavior is what I want. Otherwise they get that intermediary page. Is there any way to solve this easily?


Solution

  • Presumably when the Ajax is done you are using:

    location.href = "http://example.com/c";
    

    Change that to:

    location.replace("http://example.com/c");