从iframe中的定制页面刷新上层的标准页面

当在标准页面中插入定制VF页面时候,有没有碰到需要刷新整个标准页面的情况呢。
如果单纯依靠’location.href=”/”‘的话结果并不会如预期那样。

本篇将介绍此类问题以及解决方案。

问题的再现

1.准备一个定制对象「Sales__c」

2.新建Apex Class “ExtendPageController”

2.新建Visualforce Page “SalesDetail”

3. 在Sales__c详细Layout中添加”SalesDetail”

Edit Sales Page Layout

4.编辑详细页面的任意数据,不保存的状态下点击Refresh链接

Sales  Detail
至此我们会发现并非整个页面而只有VF页面被重新载入,
因为VF页面被嵌套在iframe中进行输出了。
Sales Detail iframe

解决方案

使用‘target=”_parent”‘属性可以解决此类问题。
如下所示:

修改visualforce page

再次确认

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

Post Tagged with , , ,