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
case commentscase comments 

Pop up window in visualforce

I have a custom button that pops up a VF in another window.  I want to be able to click save, close the pop up, and refresh the parent page.  The code looks correct, but it doesn't close the pop up window, but instead just refreshes in the pop up window.  I have turned off development on my profile and that doesn't seem to fix the problem.

 

<apex:page standardController="Opportunity" sidebar="false" showheader="false">
    <script language="JavaScript" type="text/javascript">
    function CloseAndRefresh(){
        window.opener.location.href="/{!$CurrentPage.parameters.id}";
        window.top.close();
        
    }
    </script>
    
    <apex:form >
        <apex:pageblock >
            <apex:pageBlockSection >
                
                <apex:inputfield value="{!opportunity.Titles__c}"/>
                <apex:inputfield value="{!opportunity.stagename}"/>
                <apex:commandbutton action="{!save}" value="Save" oncomplete="javascript&colon;CloseAndRefresh()"/>
                
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
    
</apex:page>
               

 

 

sambasamba

You can change window.top.close() to window.parent.close(). Then try again. If it's not work, can you sent me a dev account to my email. I will check it. Thanks.

 

Hope this helps.

 

 

Thanks,

Samba