Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

refresh parent window when closing child window

Tags:

javascript

How can I refresh the parent window when clicking the close button of a child window?

The child window is a pop-up.

like image 431
Santhosh Avatar asked Feb 20 '10 06:02

Santhosh


3 Answers

You can access the parent window using

window.opener

and refresh the parent window using

window.opener.reload()

See window.opener

like image 144
rahul Avatar answered Sep 29 '22 12:09

rahul


To refresh the parent page on close of child window use the following javascript in the popup page and call that using onunload in the popup page.

function refreshParent() 
{
    window.opener.location.reload(true);
}

<body onunload="javascript:refreshParent()">
like image 21
Chaitra A U Avatar answered Sep 29 '22 11:09

Chaitra A U


<body onunload="window.opener.reload();">

If you use this when you close your child window, the parent will be reloaded. window.opener refers to the parent window object.

like image 23
Prasanna Raghu Avatar answered Sep 29 '22 11:09

Prasanna Raghu