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
这篇关于我想检测用户何时关闭浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我想检测用户何时关闭浏览器窗口?
基础教程推荐
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- WPF 模态进度窗口 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
