在Chrome浏览器选项卡关闭时,当前的LoggedIn用户应该注销。

问题描述:

任何人都可以为以下代码提供备用,以便在Chrome中使用。

现在以下代码仅在firefox中正常工作。



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 ()
            {
                fnLogOut();
            })
         });
        function fnLogOut()
        {
            window.location.replace(ConstructClientUrl("/ViewerLogin.aspx?Logout=True"));
        }





ViewerLogin.aspx是我的登录界面。



我的要求是在chrome浏览器选项卡关闭时,当前LoggedIn用户应该注销。



我不能使用onbeforeonload函数进行chrome,因为它返回确认窗口选项卡关闭以及页面导航。



所以请给我一些最好的想法。



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.

(function()
{
(function () {


(window).bind( beforeunload,function()
{
fnLogOut();
})
});
函数fnLogOut()
{
window.location.replace(ConstructClientUrl( /ViewerLogin.aspx?Logout=True跨度>));
}
(window).bind("beforeunload", function () { fnLogOut(); }) }); function fnLogOut() { window.location.replace(ConstructClientUrl("/ViewerLogin.aspx?Logout=True")); }





ViewerLogin.aspx是我的登录界面。



我的要求是在chrome浏览器选项卡关闭时,当前LoggedIn用户应该注销。



我不能使用onbeforeonload函数进行chrome,因为它返回确认窗口选项卡关闭以及页面导航。



所以请给我一些最好的想法。



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.


您是否考虑过以下内容?案例?

*您的用户使用无线连接(例如火车),并在通过隧道时关闭窗口。

*由于停电,您的用户计算机已关闭。

*您的用户是邪恶的,断开网线,然后关闭标签。



通常的政策是:

*允许明确注销(使用注销按钮或链接.Codeproject有其中之一。

*超时后在服务器上注销(例如,用户连接上没有活动超过X小时)。

*不信任客户端。用户甚至可能关闭标签前一秒钟禁用javascript。



希望这有帮助,
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,