PDA

View Full Version : update the parent


Tussi
05-24-2004, 11:58 AM
I have a main window, it opens a small window when the user pushes a link.

How can I with javascript, do so that when the small window closes, it updates/reloads the main window?

agent002
05-24-2004, 01:14 PM
Hi Tussi,
something like this between the <head> and </head> tags of the popup window page should do it:
<script type="text/javascript">
window.onunload = function(){
if(window.opener && !window.opener.closed){
window.opener.location.reload();
}
}
</script>
:)

Tussi
05-24-2004, 03:17 PM
worked great, but when I opened a new page in the small window, it didn't work anymore?

agent002
05-24-2004, 03:24 PM
You need to make sure that code is on the page that is currently shown when the popup is closed... easiest would be to put it in an external .js file and just include it on all popup window pages using:
<script type="text/javascript" src="filename.js"></script>

Tussi
05-24-2004, 03:40 PM
thanks, got it to work :)