Skip to main content

Control Applet close

No replies
Joined: 2007-04-30

I have an Applet (using update N and the new plugin).

I would like to have some control over how the Applet is closed, specifically if the user closes the browser window or the tab in which the Applet is being displayed.

There might be unsaved data in the Applet, and the user needs to be prompted to save the data if they close the browser window.

However, I understand that the Applet will be forcibly closed if the browser is closed. I tried putting code in the destroy() method of the Applet, but the VM is forcibly terminated if the code waits for user input.

It may be possible to use javascript to capture 'onbeforeunload' and then call a method of the Applet through Javascript to display a dialog to the user. Though I am not sure how well that would work, and there is always the possibility of the user disabling the script.

Is there a clean way to control the closing of an Applet so that some interaction with the user can be done before the Applet JVM actually closes.

Thanks & Regards
Parag Shah