Refresh standard detail page from visualforce page in iframe

We may need to refresh the whole page but not only itself, when we use custom visualforce page in standard detail page,and it will not work well if we just use ‘location.href=”/”‘ by javascript.

Let me show it in this post.

The Problem

1.Prepare a custom object named Sales__c

2.Add an Apex Class “ExtendPageController”

2.Add a Visualforce Page “SalesDetail”

3.Add “SalesDetail” into the Detail Layout of object Sales__c

Edit Sales Page Layout

4.Edit any data in Detail Page and Click the Refresh link without save

Sales  Detail
Now we will find the problem that the whole page will not be refreshed, because our visualforce page is outputed in an iframe.
Sales Detail iframe

The Solution

Using ‘target=”_parent”‘ is a solution for this problem, like the following.

Change the visualforce page’s code

Try it again

Sales  Detail2
Sales Detail Refresh Good,it’s working now!

Post Tagged with , , ,