我想检测时,用户关闭浏览器窗口? [英] I want to detect when user close browser window?

查看:140
本文介绍了我想检测时,用户关闭浏览器窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我举例,我需要终止会话,当用户关闭了浏览器窗口。
我试图激发Page_Unload()不工作。
这个例子是:我有父窗口和窗口将打开它,我需要删除会话时用户关闭子窗口。
请我需要一些帮助。

I have Example and i need to kill the session when user close his browser window. i tried page_unload() not working. the example is:i have parent windows and window will open from it i need to delete session when user close the child window. please i need some help.

推荐答案

您可以用window.onbeforeunload处理程序做到这一点的职位回到登出页面。

You can do this with an window.onbeforeunload handler that posts back to a sign out page.

function CloseSession( )
{
    location.href = 'SignOut.aspx'; 
}
window.onbeforeunload = CloseSession;

这是重复的问题..这里清洁香港出

This is the duplication question.. chk out here

<一个href=\"http://stackoverflow.com/questions/287022/closing-the-browser-should-actually-clear-the-session-variables-an-asp-net-sessio\">http://stackoverflow.com/questions/287022/closing-the-browser-should-actually-clear-the-session-variables-an-asp-net-sessio

<一个href=\"http://stackoverflow.com/questions/920042/kill-server-side-session-on-browser-window-close-closed\">http://stackoverflow.com/questions/920042/kill-server-side-session-on-browser-window-close-closed

这篇关于我想检测时,用户关闭浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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