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
BroncoBoyBroncoBoy 

Visualforce Save and Close: Saves But Doesn't Close

I've seen several posts out there about this but can't get any of them to work: The expected behavior is that the save completes and then the window/tab closes.

Code:

<apex:outputPanel id="outBottom">
  <apex:commandButton oncomplete="window.close();" action="{!createTask}" value="Save Task" status="closer" rerender="outBottom"/>
   <apex:actionStatus startText="(Saving...)" stopText="" onstop="window.close(); return false;" id="closer"/>                       
</apex:outputPanel>

Has anyone found a solution to this or is there an error in my code?  Thank you in advance!
Best Answer chosen by BroncoBoy
Ashish_SFDCAshish_SFDC
Hi Bronco, 


Your popup window cannot close itself, as it didn't open itself.  I hit exactly this problem with a custom lookup page.  The close method needs to be executed from the window that created the popup.

You will need to move your close javascript method to the page that creates the window, and invoke that from the popup page.

https://developer.salesforce.com/forums/ForumsMain?id=906F000000095V9IAI


Regards,
Ashish

All Answers

Ashish_SFDCAshish_SFDC
Hi Bronco, 


Your popup window cannot close itself, as it didn't open itself.  I hit exactly this problem with a custom lookup page.  The close method needs to be executed from the window that created the popup.

You will need to move your close javascript method to the page that creates the window, and invoke that from the popup page.

https://developer.salesforce.com/forums/ForumsMain?id=906F000000095V9IAI


Regards,
Ashish
This was selected as the best answer
BroncoBoyBroncoBoy
Thank you Ashish!