1

My requirement is whenever user clicks on some custom button on child window, that window gets closed plus the parent page should be refreshed.

But only child window is getting closed and parent window is not getting refreshed.

Following is the code snippet i am using in child vf page:

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

<script language="JavaScript" type="text/javascript">
        function CloseAndRefresh(){
            opener.location.reload(true); 
            self.close();
        }
</script>

Any suggessions??

  • Does that work on non-visualforce pages ? If the problem isn't visualforce related, and pure Javascript you may be better of askign this at stackoverflow. – Samuel De Rycke Jun 4 '14 at 20:52
2

Can you try this

function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.yourAccountIdParamName}";
window.top.close();
}
| improve this answer | |
0

For anyone looking at this post for a solution, the response posted by Jai Chaturvedi here (May 27, 2014 - 5th post from top) worked for me. Good luck!

| improve this answer | |
0

If you have some parameter that is passed to popup window, you can reload parent window using the below script,

      function closeWindow(){      
            window.opener.location.href="/{!$CurrentPage.parameters.id}";
            window.top.close();
      }

In my case I am passing Id of the record as parameter to the popup window. Make sure that "Developer Mode" is not enabled. If it is enabled, it will not work.

| improve this answer | |
0

I too stuck in a similar issue, I am calling a visualforce page from a javascript button, button's code is as

window.open('/apex/addNaratives?id={!Lead.Id}&retURL=/apex/ForceWindowClose', 'Popup Name' ,"width=700, height=580, scrollbars=yes")

it is opening a new window as desired, id also being passed, now I want this, once the button on this visualforce page "Save" record which actually saving this record, is clicked the javascript window should close and it should redirect me to the Narrative detail record page. visualforce page code is as

<apex:form >
<apex:pageBlock mode="edit" title="The Insurance Agency, Inc">
<apex:pageblockButtons location="bottom">
<Apex:commandButton value="Save" action="{!saveRecord}" />
</apex:pageblockButtons>
<br/>

The narrative should answer the following topics to validate the information gathered and provide for others
a comprehensive understanding of the agency.

<br/><br/><br/>

<apex:pageBlockSection columns="1" title="Add Narrative" >
<apex:inputtextarea value="{!Nar.History__c}" label="History" cols="80" rows="6"  required="true"/>
<apex:inputtextarea value="{!Nar.Operational_Summary__c}" label="Operational Summary" cols="80" rows="6"  required="true"/>
<apex:inputtextarea value="{!Nar.Needs_Analysis__c}" label="Needs Analysis" cols="80" rows="6"  required="true"/>
<apex:inputtextarea value="{!Nar.History__c}" label="Conclusions" cols="80" rows="6"  required="true"/>


</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>  

</apex:page>
| improve this answer | |
  • 1
    Welcome to SFSE! Please take the tour and read How to Ask and How to Answer. Your answer is in one or two of the review queues, and I'm not sure that this actually answers the question. If you intended for this to be an answer to the question, please edit your answer to make it more clear how this answers the question. If this isn't an answer, but rather a question of your own, please make your own question. – Derek F Dec 24 '18 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.