用户无需单击注销按钮即可关闭浏览器. [英] user close the browser without click logout button.

查看:78
本文介绍了用户无需单击注销按钮即可关闭浏览器.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



用户登录我的网站时,我正在插入用户详细信息.

在用户注销时,我必须更新注销状态.

如果用户正确注销,我可以捕获到注销状态,但是如果用户没有单击注销按钮就关闭浏览器,那么我如何捕获用户已注销?

请帮助我解决该问题的方法.

Hi,

I am inserting user details when user login in my website.

At the time of user logout then i have to update logout status .

if user logout properly i can catch the status as logout but if user close the browser without click logout button then how can i catch the user has logout??

Please help me how to solve this problem

推荐答案

您不能,不可靠.
有一个JavaScript事件可以捕获(onunload),但它在IE中有效,但不适用于FireFox,并且onbeforeunload在Firefox中有效,但是没有简单的做到这一点"对所有浏览器都有效.此外,如果用户拔下路由器,断电,进入隧道或用尽电池电量该怎么办?如果您的应用程序在注销之前崩溃了,该怎么办?

使用会话超时来注销用户(如果以前从未注销过),如果用户尝试在没有匹配注销的情况下登录,则可以让系统正常工作.
You can''t, not reliably.
There is an javascript event you can catch (onunload) but it works in IE, but not for FireFox, and there is onbeforeunload which works in Firefox, but there is no simple "do this" which works, guaranteed, for all browsers. To add to that, what if the user unplugs the router, or has a power cut, or goes into a tunnel, or runs out of battery power? What happens if your app crashes before he logs out?

Use the session timeout to log out your user if he hasn''t before, and allow your system to work gracefully if a user tries to log in without a matching log out.


您好,
您可以使用JavaScript捕获浏览器关闭按钮单击事件,然后可以在其中调用Logout方法.
这样的东西
Hi,
You can capture browser close button click event using JavaScript and you can call the Logout method in that.
Something like this,
window.onbeforeunload = function() {
// make an Ajax call to server side Logout method.
// In the Logout method you can get/set the success status
}


您可以对方法背后的代码进行Ajax调用.请检查以下链接,
http://sandblogaspnet.blogspot.no/2009/03/calling-aspnet- server-side-function.html [ ^ ]


You can make an Ajax call to a code behind method. Please check the following link,
http://sandblogaspnet.blogspot.no/2009/03/calling-aspnet-server-side-function.html[^]


这篇关于用户无需单击注销按钮即可关闭浏览器.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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