Re: Calling Java applet function upon browser close
- From: Finomosec <fredleitenb@xxxxxxxx>
- Date: Thu, 16 Feb 2006 21:45:42 +0100
M B HONG 20 schrieb:
When I close the page, I get an error. I realize that the error is
resulting from the fact that the applet is attempting to call a
function that is not there, due to the fact that the page has already
been closed. What I am asking is whether there is a better way (such
as an "OnBeforeUnload" event or something) that I can use to accomplish
calling a javascript function upon the browser close. Any help would
be greatly appreciated.
I have a slight idea how it could work:
On page-load open a new new (small) window and send it to background:
var secondWindow = window.open("URL", "WindowName", "width=300,height=100,left=100,top=100");
window.focus();
Maybe you want to "hide" the second window.
You may try to move it out of the desktop area or resize it to 0x0.
Or you simply display a short info-text so none is irritated.
see also (german):
http://de.selfhtml.org/javascript/objekte/window.htm#open
In the second window you setup an Interval, that checks if the first window is still there:
// Second Window-Script:
window.setInterval("myCheckFunction()", 250) ;
function myCheckFunction() {
if (window.opener.closed) {
doYourExecute();
// close this (second) window ...
window.close(); // may not be possible directly ... but there was a opener-hack somehow ...
}
}
You may also add a similar observation to the first window, that repeatedly checks if the second window is still open, and if not - reopens it ...
I just found another alternative:
Instead of a second window it may work with frames ... but not that certain.
Greetings Finomosec;
.
- References:
- Calling Java applet function upon browser close
- From: M B HONG 20
- Calling Java applet function upon browser close
- Prev by Date: Re: Is There a way to design forms quickly in java?
- Next by Date: Re: Arrays as key in a HashMap
- Previous by thread: Calling Java applet function upon browser close
- Next by thread: Extracting image from binary file
- Index(es):
Relevant Pages
|