Replies Back to Article

Close and Refresh Parent

Absolutely Wizard
May 9, 2001 by Matthew Thornhill

Fantastic..........

Exactly what I was after..........Cheers Matt

refreshing page
May 12, 2001 by Steve Davis

I hate doing this in case I am totally wrong and look stupid  :P

But shoudn't that be onUnload rather than onLoad?

That's what worked for me using something similar.

Doesn't refresh...
November 26, 2001 by Eddie Appell

I used this code, and it does close the window, but the parent doesn't refresh...  I just copied it exactly as it is in your post...  Any idea what I could be doing wrong?  I'm using IE6, BTW...

 

Thanks George!

Eddie Appell

refreshing page
February 22, 2002 by Frank Williams

YOU ROCK!!!

This is what I needed

THANKS!!!

This rocks!!!
April 6, 2002 by Tim Lunceford

Thank you so much.  I have been looking everywhere for this little bit of code.  Thanks so much.

Tim

 

Cool Script
May 15, 2002 by Jason Sevilla
Thanks for the script it help a lot
Unable to make this script work
August 27, 2002 by Shaun Nelson
can you expand please
November 18, 2002 by Dave Hook
I have the same problem but dont understand point 2 of your solution...could you explain this for a novice please?
Close and Refresh Parent
January 18, 2003 by Peter Marinov

Just make in update pop-up , when data is submited to send GET variable "updated=1" and you can simply put :

<body onLoad="<? if (isset($HTTP_GET_VARS['updated'])) {echo"opener.location.reload()";}
?>">  

This is in PHP and works fine for me.

RE: Doesn't refresh...
January 2, 2004 by Jayme Lam
Im having the same problem, it works for some pages and doesnt for others. What can be the problem, i looked into everything but am having no success.
close and refresh after 5 seconds
January 19, 2005 by Kenny Darcy
Hi yea,
thanks for the code, how can I config it so as the windo will close and refresh parent after 5 seconds.

regards

Kenny
question...
February 2, 2006 by Eric Roberts

how do you do this and pass some variables along?  I tried using a form on the parent and then addressing parent.formname.element to pass on some required variables as this will refresh the page and destroy any previously passed vars instead of just doing a refresh ala the browser refresh button.  The current fix is to append the vars to the location.href value.  In doing this i also had to check to see if they are already appended, else you end up with a really long url string after opening up a few popups like this hehehe.  I would prefer to pass them on as form vars so i don't have the  ugly URL with all the vars in that.  Any ideas?

 

Eric

Simple script for close and refresh parent
April 21, 2008 by HÃ¥kan Petersson

I tested this script in IE and Firefox and worked perfect.

Place it in the headsection of the page.

<script language="JavaScript">
<!--
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
//-->
</script>

close pop up refresh parent after a few seconds
June 25, 2008 by Kenny Darcy

Below is if you have a pop up window with an insert update or delete, as the form is submitted you might want to take your user to another page that says thanks. then after 2 seconds the pop up closes and the parent page is refreshed.

<script language="JavaScript">
<!--
function refreshParent() {
  window
.opener.location.href = window.opener.location.href;
 
if (window.opener.progressWindow)
    window
.opener.progressWindow.close();
  window
.close();
}
function init()
{
setTimeout
("refreshParent()",2000);
}
//-->
</script>
</head>
<body onload="init()">