如何禁用按钮关闭浏览器的Web应用程序? [英] How To Disable Button Close On Browser For Web Application?

查看:142
本文介绍了如何禁用按钮关闭浏览器的Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于ASP.Net Framework 1.0中的Web应用程序,安全,我想按钮在浏览器关闭(X)(IE,火狐,歌剧等)禁用和理性做出的任何浏览器退出,用户只能退出与我的菜单注销的浏览器。

I have Application Web based ASP.Net Framework 1.0, for security i want Button Close (X) in browser(ie,firefox,opera etc.) is disable and reason anything make browser exit, user only can exit browser with my menu logoff.

请帮我

感谢

问候,
玉山Susandi。

Regards, Yusan Susandi.

推荐答案

您不能做到这一点,不好意思。你必须实现一个服务器端的超时机制,等等。你可以把它在相当短的超时并使用一个Ajax请求背后的幕后保持会话活着,但不能防止浏览器关闭。

You can't do this, sorry. You'll have to implement a server-side timeout mechanism, etc. You can make it a fairly short timeout and use an ajax request behind-the-scenes to keep the session alive, but you cannot prevent the browser from closing.

和真的,你不希望依赖于这样做,无论如何,因为浏览器可以的崩溃的而不是关闭,计算机可以拔掉,而不是关运转正常,等等,都没有被通知您的服务器。所以,你必须处理的事实,人们可以突然消失的反正

And really, you don't want to rely on doing so anyway, because browsers can crash rather than close, computers can get unplugged rather than shut down properly, etc., all without your server being notified. So you have to handle the fact that people can abruptly disappear anyway.

有关正常使用情况下,你可以的鼓励用户使用注销链接,而不是使用JavaScript:

For the normal use case, you can encourage your users to use the Logout link instead using JavaScript:

<script>
window.onbeforeunload = function() {
    if (loggedIn) {
        return "Please cancel and use the Logout link instead";
    }
};
</script>



...这将唠叨他们在大多数(但不是全部)的浏览器,但你不能的的他们做到这一点。

这篇关于如何禁用按钮关闭浏览器的Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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