Stop page from appearing in browser history

流过昼夜 提交于 2019-12-09 20:09:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!