Click here to Skip to main content
15,072,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can anyone please provide alternate for the below code that should in chrome.
Now the following code working fine in firefox only.

$(function ()
            $(window).bind("beforeunload", function ()
        function fnLogOut()

ViewerLogin.aspx is my login screen.

My requirement is that on chrome browser tab close, the current LoggedIn user should Log Out.

I cannot use onbeforeonload function for chrome because it is returning the confirmation window on tab close and also in page navigation.

So please suggest me some best possible ideas.

1 solution

Did you consider the following cases?
* Your user is on a wireless connection (e.g., a train), and closes the window when going through a tunnel.
* Your user's computer is shut down due to a power outage.
* Your user is evil, disconnects the net cable and then closes the tab.

The usual policy is:
* Allow logging off explicitly (with a 'sign out' button or link. Codeproject has one of these.
* Log off at the server, after a timeout (e.g., no activity on the user's connection for more than X hours).
* Don't trust the client. The user may even disable javascript one second before closing the tab.

Hope this helps,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900