How to refresh page from an embedded Visualforce page

The problem

In page layout, we can add an embedded Visualforce page into it. And sometimes, we want to refresh the parent page once we have finished our operation. Does that sound easy? Let’s try it.

First try

First, let try with the simplest Javascript:


However, this won’t work. That’s because our embedded Visualforce page is inside an iframe. location.reload will only reload the iframe for us, not the whole page.

So let’s do another try:


This usually works for iframes to refresh their parent pages. However, this still doesn’t work for our embedded Visualforce page. For some reason, the embedded iframe and the parent VF page is in a different domain so we will be getting a CORS error here.

The solution

How to resolve this? In short, this can’t be easily resolved in the client side. So we will need a form submission here.

In our html part, add this line of code:

<<span class="pl-ent">form</span> <span class="pl-e">action</span>=<span class="pl-s"><span class="pl-pds">"</span>/{!record.Id}<span class="pl-pds">"</span></span> <span class="pl-e">target</span>=<span class="pl-s"><span class="pl-pds">"</span>_parent<span class="pl-pds">"</span></span> <span class="pl-e">name</span>=<span class="pl-s"><span class="pl-pds">"</span>rform<span class="pl-pds">"</span></span>></<span class="pl-ent">form</span>>

And in our javascript

<span class="pl-c1">document</span>.<span class="pl-smi">rform</span>.<span class="pl-c1">submit</span>();

Replace record in the above code with your own record’s property name. And this will be working for you.

Subscribe to Sfdcinpractice

Subscribe to get the latest blogs and tutorials of sfdcinpractice. No spam, no trash, only the awesome posts from sfdcinpractice. 


  1. Mohsin Raza - October 30, 2017 @ 9:18 am


Leave a Reply

Your email address will not be published / Required fields are marked *