Activity Forums Salesforce® Discussions Refresh parent after child action on inline Visualforce Page

  • Shubham

    Member
    March 29, 2016 at 12:43 pm

    Hello Abhinav,

    You can achieve this by adding this javascript code snippet into your parent VF page.

    var popupwindow;
    var timer;
    //call this function onclick of custom button
    function popup(){
    popupwindow = open('/apex/ChlidPageName','Popup','height=400,width=400,left=100,top=100,scrollbars=yes,toolbar=no,status=no');
    timer = setInterval(checkWindow, 500);
    }
    function checkWindow(){
    if(popupwindow.closed){
    alert("Child window closed");
    clearInterval(timer);
    window.location.reload();
    }
    }

    I hope this might help you.

  • Ravi

    Member
    March 29, 2016 at 1:24 pm

    Hi Abhinav,
    You can refresh your parent page or a section of parent page using window.opener functionality of java-script.
    Example:
    ParentPage:

    //function to open a child page(popup)
    function popupwindow(){
    window.open('child page url');
    }
    //function to called from child page(popup)
    function refreshParent(){
    //refresh your page or section of page
    }

    Child Page:
    function closeAndRefresh() {

    window.opener.refreshParent();//call the parent function and that does thetrick
    window.top.close();

    }

    • This reply was modified 8 years, 9 months ago by  Ravi.
  • Parul

    Member
    September 19, 2018 at 9:11 pm

    Hi Abhinav,

    Apex Class:-

    public class Opp_Ext {
    private ApexPages.StandardController stdController;
    public String redirectUrl {public get; private set;}
    public Boolean shouldRedirect {public get; private set;}

    public Opp_Ext(ApexPages.StandardController stdController) {
    this.stdController = stdController;
    shouldRedirect = false;
    }

    public PageReference doStuffAndRedirect() {
    shouldRedirect = true;
    redirectUrl = stdController.view().getUrl();
    return null;
    }
    }

    Visualforce Page:-

    <apex:page standardController="Opportunity" extensions="Opp_Ext" >
    <apex:form >
    <apex:commandButton value="Do Stuff" action="{!doStuffAndRedirect}" rerender="redirectPanel" />
    <apex:outputPanel id="redirectPanel" >
    <apex:outputText rendered="{!shouldRedirect}">
    <script type="text/javascript">
    window.top.location.href = '{!redirectUrl}';
    </script>
    </apex:outputText>
    </apex:outputPanel>
    </apex:form>
    </apex:page>

    Hope this helps.

  • shariq

    Member
    September 19, 2018 at 10:35 pm

    Hi,

    You can achieve this by using Window opener functionalty of Java script.

    Example -

    function popupSlide(){
    window.open(‘URL’);
    }

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs