Just to make explicit what is implied in Abigail's message - there is no communication between the browser and the server when the browser pops up its window -- that is, no event that you can catch and script an action for.
Which is OK, since it will force you to fix the actual bug in your code, and not the symptom ;-)
If you post your CGI, we can try and figure out why it's not returning any output.