繁体   English   中英

javascript重定向后,后退按钮无法正常工作

[英]back button not working after javascript redirect

我有一个嵌入随机网站的小部件。 当用户点击时我调用服务器来更新发生的点击,服务器返回重定向到正确的页面。 问题是浏览器的后退按钮不再有效。

我使用location.href进行重定向。

我尝试了location.replace - 它保留了后退按钮,但是它会在单击小部件的页面之前进入页面(它将其替换为新页面)。

报告到服务器后如何进行页面切换并仍然允许后退按钮工作?

您无法返回自动重定向的页面。 这只是一个破损的按钮和一个沮丧的用户。

User goes to page A.
User clicks on link to page B.
Page B automatically redirects to page C with window.location.
User hits back button and momentarily goes back to page B.
Page B automatically redirects to page C with window.location.
User hits back button and momentarily goes back to page B.
Page B automatically redirects to page C with window.location.
User is sad.

显然这不起作用。 它必须像这样工作:

User goes to page A.
User clicks on link to page B.
Page B automatically redirects to page C with window.location.replace().
User hits back button and goes back to page A.
User is happy.

如果要使用后退按钮,则必须使用window.location.replace()自动重定向。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM