简体   繁体   中英

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. 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. 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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