Skip to main content

Refreshing Parent Window of Inline Visualforce Page from Child Window Opened from Inline Visualforce Page

The problem statement is From Inline Visualforce We need to open a Child window and then from that child window we need to refresh the Parent window of the Child window or redirect Parent window of the child window .

Last night ,I was struggling on how to redirect the Parent Window from the child window that was opened from the Inline window 

I tried hard on how to solve this ,but finally last resort was to post the query on salesforce stackexchange .The below is the link for the same

The error was due to Javascript security of web browser .

I tried the below script on the child window


  function test(){


Unsafe JavaScript attempt to initiate navigation for frame with URL '' from frame with URL ''. The frame attempting navigation is neither same-origin with the target, nor is it the target's parent or opener.

The browser security features don't allow navigation from child window directly since visualforce and standard detail page are in different domain.The above error is due to the same feature .

Stackexchange has really expert professionals and Eric suggested me the below solution.I am posting the same so that helps others

The Inline page on the parent window has the below code

<apex:page standardController="Account" extensions="Accountctrl">
<apex:form >
  function openwindow(){"/apex/pagereal", "myWindow", "width=200, height=100");
  function navigate(){'';//Parent function that redirects
<apex:pageBlock >
 <apex:pageBlockSection columns="1" id="Test" >
  <apex:inputcheckbox value="{!test.istest__c}" label="Same as Above">
    <apex:actionSupport event="onchange" rerender="Test" />
<apex:outputPanel rendered="{!NOT(test.istest__c)}"> 
<apex:inputField value="{!test.Campaign__c}" />
<apex:inputField value="{!test.cust_vendor__c}" />

Note that navigate function we will call from the child window and that would navigate parent frame

<apex:page >
 <!-- Begin Default Content REMOVE THIS -->
 This is your new Page


 function test(){
     window.opener.navigate();//call the parent function from child window and that does the trick

  <apex:form >
 <!-- End Default Content REMOVE THIS -->
  <apex:commandButton onclick="test()" value="Test"/>
The child window script will call the opener  window script and that in turn will redirect the parent frame .

Hope this trick will be useful .

Popular posts from this blog

Invoking Apex Callout From Process Builder

Process builder is GA in Spring 15 and one of the queries I came across was around how to invoke apex callouts from Process builder .

Before process builder came we had two common approaches of calling webservice 

1)We have outbound messages as one of the Actions for workflows.This works if other party implements the WSDL that is generated once Outbound messaging is defined with appropriate end point .

2)Most of times future method invoked through triggers allowed to do apex callouts and invoke external web service provided the future method is annotated with @future(callout=true).This provides lot of flexibility and one of the best approaches .

3)Flow triggers was in BETA and this was also one of the ways we could invoke callouts provided the Flow implements process plugin .To understand in detail how to implement process plugin refer to the below example

The purpose of this blogpost is to demonstrate the new possibility of invoking apex callout through Process Builder 

I tried initi…

Opening Modal Using Lightning Component Framework of SFDC

One of my friend from India threw a challenge .The challenge was to open a modal by using latest and greatest lightning components framework and modals design from SLDS .For the love of community I thought of sharing the entire code base that I did .

So here we start ..

Business Use Case - Need a handy SalesLeader board component that can be used to display the Sales revenue generated by each sales rep for current year in the order of decreasing total revenue .On click of the tile ,we will show detail opportunity list aggregating the revenue .

The component can be dragged in lightning design experience or in App builder lightning Page .

Video Demonstration-

SalesLeaderBoard from Mohith Kumar Shrivastava on Vimeo.

Frameworks Used -
Lightning Design Systems (SLDS) for CSSLightning Component Framework for client side logicApex aura enabled class for backend logicApproach
The component hierarchy is very important to imagine or mindmap before we dig deeper- SalesLeaderMain

Writing Test Classes For Apex Rest Service

I came across a question in a developer community on how to write Unit Test Classes for the Rest API service for POST HTTP calls

Unit Test Classes for REST API following link is very useful and inspired by this jeff had an article on his blog on how to write the test method for same .

Here is the Jeff Blog Link Test Class for REST API(Good reference for GET Rest Services)

In one of my previous blog post i demonstrated how to use native parsing technique for Rest api for User Defined Type
I wrote the Test class for the same and this post is helpful for all those searching for how to write test classes for apex rest service annotated with POST Call
Here is the Rest Service Class for which i attempted the test class
@RestResource(urlMapping='/DemoUrl/*') global with sharing class MyRestResourcedemo { global class RequestWrapper{ public Account acct; public Contact[] cons; } global class ResponseWrapper { public String StatusCode; …