0

We have a child visualforce page that opens from parent VF page using standard controller. We enter some values that needs to be updated back to parent page and close the child VF page. We want to close the child VF page. The following script is at the Child VF page but doesn't work. I referred to Question but there isn't any help on it

    function CloseAndRefresh(){
         var newWin = null;
        newWin=window.opener.location.href="/{!$CurrentPage.parameters.id}";
        
        if (window.focus){
            newWin.Focus();
        }
        
        if (NewWin != null){
            newWin.close();
        }
    }
    </script>
     <apex:pageBlockButtons location="both">
             <apex:commandButton value="Close" onclick="CloseAndRefresh();return false;"/>
             <apex:commandButton value="Save" action="{!save}" status="closer"/>
          </apex:pageBlockButtons>  
0

Here is a solution for your requirement, which opens a popup on click of a button. The popup can then send some data back to the parent and then close.

parent.page

<apex:page >
    <apex:form>
        <apex:commandLink value="Open" onclick="openWindow();return false;"/>
    </apex:form>
    <script>
        var winopen;
        function openWindow(){
            winopen = window.open('/apex/child', 'new window', 'width=100, height=300');
        }
        function closeFunction(data){
            console.log('data from child' + data);
            winopen.close();
        }
    </script>
</apex:page>

child.page

<apex:page >
    <apex:form>
        <apex:commandLink value="Close" onclick="window.opener.closeFunction('data from child');return false;"/>
    </apex:form>
</apex:page>

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.