Refresh parent window from a pop-up
June 28, 2004 · 6 Comment s
It's amazing how many times I've had to use this simple little function in projects throughout the years.
You've got a link that opens a pop up window whereupon you do something that updates your database. What you also need is for the pop up window to close and the parent window to refresh to reflect the database change.
/*
Reloads the parent window
*/
function parentReload() {
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
self.close();
}
}
The if statement is basically checking that the window that fired up the popup window is still available. Reloads the parent window
*/
function parentReload() {
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
self.close();
}
}
Tags: JavaScript

6 response s so far ↓
1 shola // May 28, 2007 at 9:25 AM
2 tosin // May 28, 2007 at 9:42 AM
3 dsa // Jun 27, 2007 at 9:26 AM
4 derya // Sep 17, 2007 at 5:58 PM
5 mike // Jan 10, 2008 at 7:52 PM
window.opener.location.reload();
my fix was:
window.opener.location.href = some_url;
6 Mika // Feb 1, 2008 at 12:29 PM
Leave a Comment