当他单击“后退"或“刷新"按钮时,我需要将页面重定向到“错误"页面.这个怎么做 [英] I need to redirect the page to Error page when he clicks the back or refresh button. How to do this

查看:71
本文介绍了当他单击“后退"或“刷新"按钮时,我需要将页面重定向到“错误"页面.这个怎么做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当他单击后退"或刷新"按钮时,我需要将页面重定向到错误"页面.

I need to redirect the page to Error page when he clicks the back or refresh button. How to do this

推荐答案

AFAIK,没有可靠的方法. 后退"按钮在浏览器的控制下,完全不必参考互联网-它可以重新显示其缓存中的任何信息,也可以直接显示它们,甚至不需要执行页面上的任何JavaScript.

你为什么要这样做?我认为这只会不必要地烦扰用户,而没有提供任何实际的好处.
AFAIK, there is no reliable way to do this. The Back button is under browser control, and does not necessarily have to refer to the internet at all - it can just redisplay whatever information it has in cache, or directly, without even needing to execute any of the javascript on the page.

Why do you want to do this? I would think it would just unnecessarily annoy the users, without providing any real benefits.


我自己找到了解决方案:window.onbeforeunload = function(){var href ="Error1.aspx" ;//(这是重定向页面网址)window.open(href); }
i find the solution myself: window.onbeforeunload = function () { var href = "Error1.aspx";//(this is the redirect page url ) window.open(href); }


为什么?

我想你要这样
注销后浏览器后退按钮问题 [
Why?

I think you want like this
Browser back button issue after logout[^]


这篇关于当他单击“后退"或“刷新"按钮时,我需要将页面重定向到“错误"页面.这个怎么做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆