且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

禁用浏览器窗口上的浏览器后退按钮

更新时间:2021-07-15 07:29:37

ASP的方法仅在服务器上起作用;它不能用于影响浏览器的行为.您可以使用客户端脚本语言(例如Javascript)来更改浏览器中的某些内容,但是禁用后退"按钮不是其中之一.简而言之,您无法做自己想做的事.

可以要做的是创建一个中间重定向页面.在页面A上输入数据,然后用户单击Submit.数据被处理,并且用户被发送到页面B.页面B上唯一的内容是meta HTTP-EQUIV="REFRESH"标记,该标记将立即将用户重定向到页面C,这告诉用户已接收到数据.如果用户单击页面C中的后退"按钮,则他们将转到页面B,这将立即将他们重定向回页面C.

但是请注意,这种强制重定向对于您的用户而言非常烦人.
ASP works only on the server; it cannot be used to affect the behavior of the browser. You can use client scripting languages like Javascript to change some things in the browser, but disabling the Back button is not one of them. In short, you cannot do what you want.

What you can do is create an intermediate redirect page. The data is entered on page A and the user clicks Submit. The data is processed and the user is sent to page B. The only content on page B is a meta HTTP-EQUIV="REFRESH" tag that will immediately redirect the user to page C, which tells the user that the data has been received. If the user clicks the back button from page C, they will go to page B, which immediately redirects them back to page C.

Be warned, though, that this kind of forced redirection tends to be very annoying for your users.


这是一个非常受欢迎的问题.在很多地方都可以找到解决方案.

查看这些讨论:
如何在asp.net中禁用后退按钮 [ ^ ],
http://论坛. devarticles.com/javascript-development-22/is-there-a-way-to-disable-the-back-button-5408.html [
This is a very popular question. There are many place where you can find a solution.

Check out these discussions:
how to disable back button in asp.net[^],
http://forums.devarticles.com/javascript-development-22/is-there-a-way-to-disable-the-back-button-5408.html[^].

Good luck,
—SA