I want to detect when user close browser window?(我想检测用户何时关闭浏览器窗口?)
问题描述
我有示例,我需要在用户关闭浏览器窗口时终止会话.我试过 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;
这是重复问题.. chk out here
This is the duplication question.. chk out here
关闭浏览器实际上应该清除会话变量一个 ASP.net 会话 id
https://stackoverflow.com/questions/920042/kill-server-side-session-on-browser-window-close-closed
这篇关于我想检测用户何时关闭浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我想检测用户何时关闭浏览器窗口?
基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
