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
这篇关于我想检测用户何时关闭浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我想检测用户何时关闭浏览器窗口?
基础教程推荐
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 如果条件可以为空 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 从 C# 控制相机设备 2022-01-01
- 将数据集转换为列表 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
