PDA

View Full Version : onUnload with a popup window


raoul
09-27-2002, 11:00 AM
Hi

I have a popup window. I would like to execute a couple of events when this window is closed.

1. Ask the user to confirm closing the window
2. if 1. is yes -> update a MySQL table -> close the window.

I understand that IE supports something like onBeforeunload. Is there a different way (cross-browser) to ask for confirmation?

Then the part to update the MySQL table. Ideally I would like to cancel the close procedure and let the Flash movie, inside the popup, update the MySQL table through php and close the window afterwards with this.close().

Is it possible to trace an onClose event and break it off?

If not then I guess I will have to use a new popup window, that is executed on the onUnload event, to update the MySQL table. I experimented with this and it seems that the onUnload event is not executed in a popup window (the new popup doesnot appear), is this true? It works fine from the main window!

Hope anyone can help me with this.
thanks,
Raoul

Mr J
09-27-2002, 03:13 PM
onunload= "FUNCTION()"

in the opening BODY tag

or

onunload=FUNCTION

in a script

FUNCTION being the things you want to do

:)

adios
09-27-2002, 04:18 PM
http://www.codingforums.com/showthread.php?threadid=6823

raoul
09-27-2002, 07:01 PM
Thanks both!

Mr. J, that is what I first tried.

adios, thanks for that link.

I guess there is no cross-browser solution to stop closing a window or at leas asking for confirmation.

For the MySQL part, it seems this solves the problem: onUnload triggers a function in the opener window which will open a new popup window with a short message and the php code to update the MySQl table.

It is not ideal but it does the job.

Thanks again,
Raoul