View Full Version : reload parent on pop-up unload
07-15-2004, 12:05 AM
i have been trying to find a way to make JS to something (explained below) but it doesnt work. does anyone have any suggestions?
the parent window opens a pop-up via JS. parent window may optionally have its name set to "main" (window.name = "main"). when the user closes the pop-up (like by clicking the "X" on the titlebar in Windows) the pop-up executes code to refresh the parent window.
any help would be nice, thanks in advance
07-15-2004, 12:16 AM
In body tag of your popup window, try this: (untested)
But I'm pretty sure that will work.. let me know.
07-15-2004, 12:25 AM
This is unreliable in IE. Its a special feature that MS added(also known as a flaw).
I'd recommend instead adding an onFocus event handler right before the pop-up is created. Then when ever they focus back on the generating page, it can use that onFocus to check if the pop-up elemnt is there.
I'll code it up for you in a second.
07-15-2004, 12:33 AM
oo...thanks a lot and thats for the code you are doing
btw...do u know why IE show the directory of the file (pop-up) in the pop up when i have this:
function reloadMainPage ()
somewhere in the head and this for a link in the pop-up:
07-15-2004, 12:55 AM
Sorry this took a bit, had some work stuff to attend to, heh.
window.onfocus = checklive;
function checklive ()
<a href="#" onClick="focuser()">Link for pop-up</a>
07-15-2004, 01:06 AM
um...i am sorta lost how it works
well from "window.onfocus = checklive;" down
is it possible to
1. generate a pop-up
2. when the pop-up is out of focus, make the parent check if the pop-up still exists and have a conditional
if (pop-up is closed)
then refresh yourself (parent)
sorry, i still trying to explain things in a sorft of VBish way
07-15-2004, 07:41 AM
Didn't sad69's suggestion work?
It can be modified a bit to ensure that the opener is still open before reloading it.
<body onunload="if (opener && !opener.closed) opener.location.reload(1);">
Or you can't use it because the popup navigates to other pages too?
07-15-2004, 04:59 PM
onUnload doesn't seem to respond correct in IE
If you do a google search you will find multiple people backing this up, or you can try it yourself :)
07-15-2004, 05:47 PM
aight i will look aroung with Google. i still think the average user will probably click a link to close the pop-up using the link rather than the ( X ) and its a minor inconvenience with this IE 'feature' anyways
07-15-2004, 06:57 PM
My method seems to work. It reloads when ever you regain focus on your main page.
08-24-2004, 08:00 PM
I too, was having this same problem. The solution provided by SAd69 does indeed work. It even works for a window that's part of a frameset.
Thanks SAd69 for the help.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.