[英]Previous page not loading after clicking browser back button after a page redirection
From a sign up success thanks page I am redirecting to another webpage using window.location object.从注册成功感谢页面,我使用 window.location 对象重定向到另一个网页。 But after redirecting, clicking browser back button shows the sign up page not the sign up success thanks page.但重定向后,单击浏览器返回按钮显示注册页面而不是注册成功感谢页面。 Tried the same scenario without pressing the back button instead used window.history.go(-1) , this works fine it loads the success thanks page itself.在不按后退按钮的情况下尝试了相同的场景,而是使用了 window.history.go(-1) ,这很好,它加载了成功感谢页面本身。
Use window.location.href = 'YOUR LINK'
使用window.location.href = 'YOUR LINK'
Right now, you are replacing the current page url (success page) with the new page (redirected page), so when you go back you go to the previous page in the history stack, which is the sign up page.现在,您正在用新页面(重定向页面)替换当前页面 url(成功页面),因此当您返回时,您会转到历史堆栈中的上一页,即注册页面。
You can also use history.pushState() to add entries to the location history您还可以使用history.pushState()将条目添加到位置历史记录
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.