如果浏览器在asp .net中关闭,则从浏览器注销? [英] log out from browser if the browser closes in asp .net?

查看:62
本文介绍了如果浏览器在asp .net中关闭,则从浏览器注销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求有点复杂。
用户使用Web浏览器访问数据库,如果用户关闭活动页面而不是注销会话,则访问数据库 - 该会话需要自动注销。
可以有人指导我如何制作这个吗?
我在主页面中使用了jquery。

my requirement is bit of complicated . an user is accessing the data base using the web browser, while accessing the data base if the user is closed the active page instead of log out the session - that session needs to be log out automatically. can some one guide me how to make this ? i am used jquery - in the master page.

onbeforeunload - 我收到消息离开页面或留在此页面。
即使我在登录时收到此消息,也查看主页。

onbeforeunload - i am getting message leave the page or stay with this page. even i am getting this messages while login and and view the home page too.

推荐答案

这是示例代码

  window.onbeforeunload = function () {
   return 'You want to leave?';
};​​

参见demo 这里

我认为可以发送ajax请求,你可以看到你的服务器用户关闭浏览器的选项卡。

I think its possible to send an ajax request and you can saw your server that the user closed the browser's tab.

此外,这是一个名为jquery.idle的jquery插件,用于识别用户是否处于活动状态。

Also this a jquery plugin called jquery.idle, which is used to identify if the user is active.

请参阅此检测空闲时间在优雅的JavaScript中会给你更多的想法。

Refer this Detecting idle time in JavaScript elegantly will gives you more idea.

这篇关于如果浏览器在asp .net中关闭,则从浏览器注销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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