leo-veio Posted March 14, 2013 Posted March 14, 2013 Hi, Is it possible kill a session when the browser is closed? Tks, Léo Quote
patmap Posted March 14, 2013 Posted March 14, 2013 Hi, Put this code in MainForm->ExtEvents->OnBeforerender : window.onbeforeunload = function() { ajaxRequest(sender, 'SessionClosed', [] ); alert("Session Closed"); // You can remove this line. only for test }; And put this code on MainForm->OnAjaxEvent : If SameText( EventName, 'SessionClosed' ) Then Begin UniSession.Terminate( ); UniSession.UniApplication.Terminate( ); End; Work on FF, Chrome, IE Regards 5 Quote
Administrators Farshad Mohajeri Posted March 15, 2013 Administrators Posted March 15, 2013 Nice tip. Thanks. BTW, this should work too: If SameText( EventName, 'SessionClosed' ) Then Begin UniSession.Terminate( ); End; 1 2 Quote
maher Posted March 15, 2013 Posted March 15, 2013 Hi, All It's work just when MainFormDisplayMode = mfWindow !!! it's not work with MainFormDisplayMode = mfPage !!! How can I implement it on MainFormDisplayMode = mfPage ? Thanx Maher Quote
patmap Posted March 15, 2013 Posted March 15, 2013 Hi, All It's work just when MainFormDisplayMode = mfWindow !!! it's not work with MainFormDisplayMode = mfPage !!! How can I implement it on MainFormDisplayMode = mfPage ? Thanx Maher Hi, No problem, Put this code in : MainForm->ClientEvents->ExtEvents->1-Ext.form.formPanel->onBeforeRender See picture Regards Quote
patmap Posted March 15, 2013 Posted March 15, 2013 Hi Mr.Farshad I do not know why three posts were added. Please delete extra posts. Thanks Regards Quote
maher Posted March 15, 2013 Posted March 15, 2013 Thank you patmap , شكرا it's work , but i have another problem, I used the "onbeforeunload function" to confirm Exit, window.onbeforeunload = function{ retrun "Are you sure you want to leave My system? The system will Terminate!"; } where i can put the code ajaxRequest(sender, 'SessionClosed', [] ); Thank you Quote
patmap Posted March 15, 2013 Posted March 15, 2013 Thank you patmap , شكرا it's work , but i have another problem, I used the "onbeforeunload function" to confirm Exit, window.onbeforeunload = function{ retrun "Are you sure you want to leave My system? The system will Terminate!"; } where i can put the code ajaxRequest(sender, 'SessionClosed', [] ); Thank you Hi, Browsers act different in this case and you cant hope to do in all browser you can add this code Instead of the previous code: window.onunload = function() { ajaxRequest(sender, 'SessionClosed', [] ); }; window.onbeforeunload = function() { return "Click Leave this page to Session Closed."; }; But this code run on FF and dont run on Google chrome. There are not %100 safe solution for confirming ! Regards Quote
aln02 Posted March 18, 2013 Posted March 18, 2013 IMHO, it is better to place this code in MainForm.Script. It works in both cases (mfPage, mfWindow) for example: function bunload(){dontleave="Are you sure? The program will be closed!";return dontleave;};function ounload(){ajaxRequest(MainForm.window, 'SessionClosed', [] );};onbeforeunload = bunload;onunload=ounload; for me, it works on FF, IE, Chrome. But Opera doesn't support both events (((. 2 Quote
mehmet07 Posted December 19, 2013 Posted December 19, 2013 i can not working Could please send me samples ? Thank you Quote
ChenHaibin Posted December 20, 2013 Posted December 20, 2013 If use this method in loginform it does not work . I use unigui 0.941024 Quote
mehmet07 Posted December 21, 2013 Posted December 21, 2013 i not use login form. i use mainform. my unigui version : 0.93.0.996 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.