我如何使用会话变量而不是javascript禁用前进和后退按钮 [英] how do i disable forward and backward button using session variable and not javascript

查看:71
本文介绍了我如何使用会话变量而不是javascript禁用前进和后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用会话变量禁用浏览器的前进和后退按钮

how do i disable forward and backward button of my browser using session variable

推荐答案

后退"浏览器按钮(或任何其他浏览器按钮)实际上不能被Web应用程序禁用,因为安全上下文不允许这样做.

我们可以做的是以某种方式确保浏览器不会缓存网页(这将导致后退",前进"按钮变灰),这可以通过过期响应轻松完成. >. ASP.NET 2.0中的代码:
The "Back" browser button (or any other browser button) cannot be actually disabled by a web application as the security context will not allow this.

What we can do is to somehow make sure that browser does not cache the web pages (which will cause the"Back" "Forward" buttons to grey out), and this can be easily done by expiring the Response. The code for this in ASP.NET 2.0:
// Code disables caching by browser. Hence the back browser button
// grayed out and could not causes the Page_Load event to fire 
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();


会话变量只是服务器端,对浏览器没有影响.
A session variable is only server side and will have no effect on a browser.


无论您使用什么,都无法禁用前进和后退按钮.就像其他人说的那样,会话在服务器上,因此即使有可能尝试捕获它,并停止它的运行,但对于那些决心不足以杀死正在使用的javascript的人来说,除了可能告诉您是否阻止该会话外,没有其他方法可以参与该会话.

在我看来,您似乎知道一些流行词,仅此而已.您应该阅读一本基础书籍,一旦了解了ASP.NET是什么以及它的作用,您将知道为什么这不是一个可以回答的问题.
There is no way to disable the forward and back buttons, no matter what you use. As someone else said, the session is on the server, so even where it''s possible to try to catch it, and stop it working for people who are not determined enough to kill the javascript you''re using to do that, there''s no way the session can be involved, except perhaps to tell you if you''re blocking it or not.

It sounds to me like you know a few buzzwords and that''s about it. You should read a basic book, once you understand what ASP.NET is, and what it does, you''ll know why this was not a question that could be answered.


这篇关于我如何使用会话变量而不是javascript禁用前进和后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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