function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Close The PopUp(Child Window) and refresh Parent Window ?


I want to know that how would i refresh Parent Window on Clicking of Save/Submit button on PopUp window or we can say Child window.

For this I used JavaScript ;


<script language="JavaScript" type="text/javascript">
 function CloseAndRefresh(){


On Submit :


<apex:commandButton action="{!save}" onclick="CloseAndRefresh()" value="Save"/>


But It doesn't Work .

Please Help ..


Hey Sheffy,


It depends, if the parent window is a Vf page and your child window is also a VF page, than you can refresh the parent window because your both the pages are on same domain.


In case you want to refresh the standard salesforce page (parent page) from a custom VF page (child page), this wont happen as salesforce saves it standard application pages on a different domain than Vf pages.


Try this:



    window.opener.location.href = window.opener.location.href;   




This is not working... :(


Are you getting any error?


Can you confirm if the parent window is a VF page and what is the URL of your parent window and child window?


not an error,

but crome going to stop work i.e. I'm not able to click anywhere in different tab.


url is same ...

Imran MohammedImran Mohammed

When you open the child window, you can assign it to a variable like


var childWin;//declare global

var intervalId;// declare global


//Code to invoke the popup

childWin =;

intervalId = window.setInterval('checkIfChildWindowIsClosed()', 5*1000);


//add thios function

function checkIfChildWindowIsClosed()





       window.parent.location.href = window.parent.location.href;




Let me know if you have any questions

Imran MohammedImran Mohammed

To remind, add the code i posted into the javascript code of your parent and not the child.

From Childs code remove opener.location.reload(true);


Even though standard pages are hosted on different domains, they can still be refreshed from VF page.




Can you please tell me how can I refresh standard page layout from VFP. I am involving VFP by onclick Javascript function and calling my page by showmodaldialog.

Please let me know how can I refresh standard page layout from this pop up when I save a record.

Thank you!





Any luck? I'm having the same problem. It doesn't seem like there's any way to do this since it's cross domain - unless Salesforce opened up some sort of cross domain way to tell the parent to refresh.


Am I missing something?


I worked with 

//Get SFID from URL
var sfid = location.href.replace(/^.*salesforce\.com\/([^\/]+).*$/, '$1');
window.childWin ='/apex/ApplyChecklistTemplate?id=' + sfid, 'ApplyChecklistTemplate', 'height=550,width=750,location=yes,menubar=no,status=no,toolbar=no');
window.intervalId = window.setInterval('window.checkIfChildWindowIsClosed()', 5*1000);
//add check function to window
window.checkIfChildWindowIsClosed = function()
        window.parent.location.href = window.parent.location.href;

 This works pretty well for me. Though, sometimes the 5-second interval seems too long... i might shorten it up a bit to make it flow better.


Here is the solution to your problem and also it considers cross domain issues.


Jerry ClifftJerry Clifft
kevingwynnkevingwynn your solution works great for me, thanks! Cross domain, cross object...
Thanks !!
but using above method..(Croos domain)
I am getting error like object doesn't support this property or method in IE