Re: Calling Java applet function upon browser close



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



Relevant Pages

  • Re: What is wrong with WindowsXP CD?
    ... When you boot from the Windows XP setup CD, ... BIOS setup for Legacy USB devices? ... FAIL to strike any key during a few second window of opportunity, ...
    (microsoft.public.windowsxp.general)
  • Re: CMap
    ... Will map with vector give any performance issue? ... First Window Info.: struct ... Second Window Info: struct ... First window displays the book information. ...
    (microsoft.public.vc.mfc)
  • Re: CMap
    ... First Window Info.: struct ... First window displays the book information. ... and second window displays current status of that particular book. ... assume, to complete print one book - 10 weeks.First window will have only one entry per book, and second window will have more than one entry per book. ...
    (microsoft.public.vc.mfc)
  • Re: Need help with macro
    ... the IE that is causing a 2nd window to open or an active X is interfering ... "Walter Briscoe" wrote: ... IE.Navigate2 URL opens a second window. ... I needed to get the table starting with the string "Trading ...
    (microsoft.public.excel.programming)
  • Re: Make two windows appear active at the same time
    ... in the second window - and returning MA_NOACTIVATE. ... explicitly set the focus back to the first window. ... The button hides the focus rectangle (because it receives ...
    (microsoft.public.win32.programmer.ui)