我的要求是复杂一点。 一个用户使用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.
这是样品code
window.onbeforeunload = function () {
return 'You want to leave?';
};
看演示这里
我认为它可以发送一个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插件称为jquery.idle,它是用来识别该用户是否活跃。
Also this a jquery plugin called jquery.idle, which is used to identify if the user is active.
请参照本Detecting空闲时间在JavaScript优雅会为您提供更多的想法。
Refer this Detecting idle time in JavaScript elegantly will gives you more idea.