Replies Back to Article
Close and Refresh Parent
Fantastic..........
Exactly what I was after..........Cheers Matt
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.
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!
Thank you so much. I have been looking everywhere for this little bit of code. Thanks so much.
Tim
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.
thanks for the code, how can I config it so as the windo will close and refresh parent after 5 seconds.
regards
Kenny
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
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>
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()">