Flex 3中浏览器关闭时如何处理注销?
我的项目有审计模块,其中包括要记录的用户的每一个操作。
当用户关闭浏览器时,有关注销的审核必须存储在数据库中。
我在网上找到了一种解决方案,但是在我的机器的IE中可以工作,但在朋友的机器的IE中却无法工作,为什么? 代码是:
window.onbeforeunload = clean_up;
function clean_up()
{
var flex = document.${application} || window.${application};
flex.myFlexFunction();
}
我将这段代码放在flex src下的html-template文件夹中的index.template.html文件中。
我还将以下代码放置在我的主 application.mxml 文件中:
ExternalInterface.addCallback("myFlexFunction",btnLogout);
并定义了注销函数。
My project had audit module, which includes each and every action of the user to be recorded.
When the user closes the browser the audit regarding the logout has to be stored in the database.
I found one solution on the net, but it is working in my machine's IE but failed to work in the friends machine's IE why?
The code is:
window.onbeforeunload = clean_up;
function clean_up()
{
var flex = document.${application} || window.${application};
flex.myFlexFunction();
}
I placed this code in the index.template.html file in the html-template folder under flex src.
I also placed the below code in my main application.mxml file:
ExternalInterface.addCallback("myFlexFunction",btnLogout);
and I defined the logout function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,这是交易。无法可靠地完成。如果这是为了审计……那么你就不走运了,一开始就提供了一个半生不熟的方法。
为什么?
转到任务管理器,终止 IIS 进程 - 没有任何日志记录。没有审核。因此 - 该解决方案很可能无法满足法律审核要求;)
另一种方法:
这样您就可以意识到客户端何时不再连接。不会阻止用户拔出网络电缆并继续查看,因此审核方法调用失败应该会擦除 HTML 内容;)
但至少您也可以处理浏览器崩溃/终止。
Ok, here is the deal. CAN NOT BE DONE RELIABLY. If this is for audit... you are out of luck and deliver a half baked approach to start with.
Why?
Go to your task manager, kill the IIS process - nothing logs out. No audit. Ergo - the solution does most likely not fulfill the legal audit requirements ;)
Another approach:
This way you realize when the client does not connect anymore. Does not stop the user from pulling the network cable and conrinuing viewing, so a failure of the audit method call should wipe the HTML content ;)
But at least you handle browser crashes / terminations, too.