[英]Redirect to error page when the browser back button hit?
I want to redirect to my Error page. 我想重定向到我的错误页面。 If the user clicks the Back button in my web application.
如果用户单击我的Web应用程序中的“后退”按钮。 I want to achieve this simply in Javascript.
我想在Javascript中实现这一点。 Do anyone knows?
有人知道吗?
You can't due to a browser security restriction. 您不能因浏览器安全限制。 A work around would be to check if the user navigates away from the page via
onbeforeunload
or onunload
fire. 解决方法是检查用户是否通过
onbeforeunload
或onunload
fire导航离开页面。
You can redirect to any page you like in Javascript with... 你可以在Javascript中重定向到你喜欢的任何页面...
window.location.href = 'URL of the page you want to go to';
However, detecting if the browser's back button has been hit, to my knowledge, is not something that you can do. 但是,据我所知,检测浏览器的后退按钮是否已被击中,这不是您可以做的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.