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 :

 

  IfSameText(EventName,'SessionClosed')Then
  Begin
    UniSession.Terminate();
    UniSession.UniApplication.Terminate();
  End;

 

Work on FF, Chrome, IE

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

Hi,

No problem,

Put this code in :

MainForm->ClientEvents->ExtEvents->1-Ext.form.formPanel->onBeforeRender 


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 (((.