[英]How to prevent user from going back to previous page after logout in polymer
I am working on polymer app where the landing page itself is the sign-in page and after the user logs out successfully i am redirecting him to sign-in page like this 我正在研究聚合物应用程序,其中登录页面本身就是登录页面,并且在用户成功注销后,我将他重定向到这样的登录页面
window.history.pushState({}, null, '/');
window.dispatchEvent(new CustomEvent('location-changed'));
now if the user clicks browser back button he will be taken to previous Url.How do I prevent this from happening. 现在,如果用户单击浏览器后退按钮,他将被带到上一个网址。如何防止这种情况发生。
There is no proper way to change the history
object of window
. 没有适当的方法来更改
window
的history
对象。 But, here are some crazy ideas you can try: 但是,您可以尝试以下一些疯狂的想法:
history.back()
and make it null if user is logged out. history.back()
并在用户注销后使其为null。 location.replace("you home page")
to take him back to home page. location.replace("you home page")
将其带回主页。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.