1

I have a Vf page with save button. i am calling a controller method in the VF page. I would like to close the VF page once the save method is executed.

   <apex:commandButton value="Save" action="{!Save}"/>

I think we can close the page using javascript function.

Thanks

Prady

Prady
  • 10,978
  • 39
  • 124
  • 176

1 Answers1

3

Here's the easiest way I've found to accomplish this.

Create a Visualforce Page (I have the same page named "CloseMe") with this Markup:

<apex:page >
    <script type="text/javascript">
        window.close();
    </script>
</apex:page>

Then, redirect (by JavaScript or Apex PageReference) to the page.

Also, make sure all Profiles have the necessary security to access the page.

Instead, you could try using an ActionFunction that calls the Apex Save action, then put the window.close(); JavaScript on the OnComplete ActionFunction parameter, but I think that's unnecessarily complicated.

Community
  • 1
  • 1
Matt K
  • 7,207
  • 5
  • 39
  • 60