简体   繁体   English

IE 7和IE 8中的浏览器关闭事件

[英]Browser Close event in IE 7 and IE 8

I know there are many posts in the forum on browser close event. 我知道论坛上有关浏览器关闭事件的帖子很多。 But still thought of posting it. 但是仍然想到了发布它。 How do I get to fire the onbeforeunload event correctly all the time. 我如何一直正确地触发onb​​eforeunload事件。 As I see, in some client browser it works and in some it does not. 如我所见,在某些客户端浏览器中它可以工作,而在某些客户端中则不能。

When I used the onbeforeunload event, I used to get IE warning, saying do you want to run ActiveX scripts. 当我使用onbeforeunload事件时,我曾经收到IE警告,说您要运行ActiveX脚本。 To avoid that I used the folowing code 为了避免这种情况,我使用了以下代码

<!--doctype html>
<!-- saved from url=(0014)about:internet -->

Can anyone let me know the standard method to be used. 任何人都可以让我知道要使用的标准方法。 All i need to do is when user closes the browser without clicking on sign out button, I need to update the logout field in DB for that users login entry 我需要做的就是,当用户关闭浏览器而不点击退出按钮时,我需要为该用户的登录条目更新数据库中的注销字段。

Any help is appreciated. 任何帮助表示赞赏。

Thanks and Regards, Sanjai Palliyil 感谢和问候,Sanjai Palliyil

That's not a reliable (or safe) way to end an authenticated user's session. 这不是终止经过身份验证的用户会话的可靠(或安全)方法。

  • What if they don't close the browser? 如果他们不关闭浏览器怎么办? The user is still logged in and if someone else uses that browser they could use that session? 用户仍处于登录状态,如果其他人使用该浏览器,他们可以使用该会话吗?

  • What if a user opens multiple tabs then closes one of them? 如果用户打开多个标签然后关闭其中一个标签怎么办? They 他们
    would be logged out incorrectly. 将被错误地注销。

The correct way to end an authentication session is to let it expire after several minutes of inactivity. 结束身份验证会话的正确方法是让它在闲置几分钟后过期。 On each new request you reset the timer and, independently, a recurrent service/process ends those sessions that have exceeded the activity timeout. 在每个新请求上,您都重置计时器,并且循环服务/进程独立地结束那些超出活动超时的会话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM