问题
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?
回答1:
Presumably when the Ajax is done you are using:
location.href = "http://example.com/c";
Change that to:
location.replace("http://example.com/c");
回答2:
Use ajax in A to load B into A.
回答3:
Nope. That's a function of the browser itself, and not something generally exposed to the page's desires. You'd be better off having page A do an AJAX call instead of loading page B in the main window at all.
来源:https://stackoverflow.com/questions/1388384/stop-page-from-appearing-in-browser-history