简体   繁体   English

浏览器后退按钮命中时重定向到错误页面?

[英]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. 解决方法是检查用户是否通过onbeforeunloadonunload 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.

相关问题 如果我在 web 浏览器中点击返回按钮,重定向页面? - Redirect page if I hit back button, in the web browser? 单击浏览器的后退按钮时,将用户重定向到页面 - Redirect users to a page when they click on back button of the browser 按浏览器后退按钮但不工作时尝试重定向到某个页面 - trying to redirect to some page when pressing browser back button but not working Href # 页面上的链接需要在浏览器上点击两次后退按钮 - Href # Link on page Requires back button to be hit twice on browser 点击浏览器后退按钮时哪种解决方案最佳 - Which solution is best when the browser back button is hit 在特定页面上单击浏览器后退按钮后如何重定向到主页 - How to redirect to home page after clicking browser back button, when on a particular page 单击浏览器的后退按钮时如何在主页上重定向 - how can i redirect on the home page when i click on browser's back button 请单击浏览器后退按钮时如何使用 Vanilla Javascript 重定向页面? - Pls how can i redirect a page using Vanilla Javascript when the browser back button is clicked? 单击后退按钮时重新加载浏览器页面 - reload browser page when click back button 需要使用浏览器的“后退”按钮重定向到首页 - Need to use the browser's back button to redirect to the home page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM