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
这篇关于我想检测用户何时关闭浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我想检测用户何时关闭浏览器窗口?
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
