| Author |
Action on close
|
Serge Adzinets
Ranch Hand
Joined: Nov 26, 2002
Posts: 166
|
|
Hi, All, We need to invoke a clean-up action on the server-side when the browser window is being closed. Now we open a new window in onUnload() event and do the clean-up request from there. But in latest version of IE user can disable opening of new window. Any other possibilities to do this?
|
Best Regards,<br />Serge
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
Not on the client side. Also the window will notopen if they have pop up blockers installed. You are going to have to deal with it on server side.
|
 |
Yuriy Fuksenko
Ranch Hand
Joined: Feb 02, 2001
Posts: 411
|
|
Well, if you really want to handle it with JavaScript, than here is the solution: <BODY ONUNLOAD="f1()"> <SCRIPT> function f1(){ document.myform.submit(); alert("You are about do leave the page"); } </SCRIPT> <FORM NAME="myform" ACTION="http://some.cleanup.url/cleanIt"> <INPUT TYPE="HIDDEN" VALUE="true" NAME="closing"> </FORM> </BODY> An alert needed there to create a time delay, otherwise browser (I had that with IE) may close before submiting a form. the form will be submitted and handles by a server. Aside from that, I would really suggest you to consider some server side solution. For example, using J2EE, I would use reasonable session timeout and session listener implementation to perform your cleanup task.
|
 |
Serge Adzinets
Ranch Hand
Joined: Nov 26, 2002
Posts: 166
|
|
Guys, thanks for your answers, I'm aware that the clean-up may be done on the server-side via the session timeout, but it's not the desired behavior. Showing the alert dialog will not be accepted either.
|
 |
Yuriy Fuksenko
Ranch Hand
Joined: Feb 02, 2001
Posts: 411
|
|
By the way Serge, how are you going to handle power interruption in a client neiborhood? Also, you might wanna think about that "Reset" and "On/Off" buttons on computer, Task Manager, user not closing a browser, but dragging another file into it and so on
|
 |
Serge Adzinets
Ranch Hand
Joined: Nov 26, 2002
Posts: 166
|
|
Hi Yuriy, I didn't say we were going to use clean-up ONLY if invoked from client. The session & stateful session beans do have a timeout as well, but it's more convenient to do it as soon as the client closed the browser. Suppose we have a concurrent license software purchased for 2 clients and the client session timeout is 8 hours (a real requirement). Nothing perfect, even can't be sure that ejbRemove() will be called
|
 |
 |
|
|
subject: Action on close
|
|
|