cdonnel
09-25-2003, 11:42 AM
I need help with a javascript error when I try to close a popup window.
The window is opened with a function "go" that is called from the main window with a link to the contents of the popup window. A link in the popup window uses the function "goBack" to get back to the main window. This function includes a Timeout to close the popup after 10 seconds.
This seems to work well as long as you return to the main window via a link in the popup. However, if you leave the popup by just clicking on the main window, the popup remains open in the background. I've tried two fixes, neither of which was satisfactory:
(1) onBlur="window.close()" in the body tag of the popup. This caused the popup to close when internal links (such as "top of page" or "print page") were clicked.
(2) onFocus="winPop.close()" in the body tag of the main window. This worked, but it caused a javascript error, because the first time the page is loaded there is no popup window to close.
I think what I need is something in the main window to say, "If winPop exists and if it is open, close it."
If you can help, please be very specific: Exactly what is the script, where does it go, and how is it called?
Thank you.
Carol
The window is opened with a function "go" that is called from the main window with a link to the contents of the popup window. A link in the popup window uses the function "goBack" to get back to the main window. This function includes a Timeout to close the popup after 10 seconds.
This seems to work well as long as you return to the main window via a link in the popup. However, if you leave the popup by just clicking on the main window, the popup remains open in the background. I've tried two fixes, neither of which was satisfactory:
(1) onBlur="window.close()" in the body tag of the popup. This caused the popup to close when internal links (such as "top of page" or "print page") were clicked.
(2) onFocus="winPop.close()" in the body tag of the main window. This worked, but it caused a javascript error, because the first time the page is loaded there is no popup window to close.
I think what I need is something in the main window to say, "If winPop exists and if it is open, close it."
If you can help, please be very specific: Exactly what is the script, where does it go, and how is it called?
Thank you.
Carol