Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I opened a Popup from an inline VF page in SFDC and then after some action I was able to close the window but needed a refresh of the Top window from inline frame .

My code is as below for opening a pop up.Note this is inline page

<apex:page standardController="Account" extensions="Accountctrl">
 <apex:form >
 <script>
   function openwindow(){
      window.open("/apex/pagereal", "myWindow", "width=200, height=100");
   }
 </script>
 <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:inputcheckbox>
  <apex:outputPanel rendered="{!NOT(test.istest__c)}"> 
<apex:inputField value="{!test.Campaign__c}" />
<apex:inputField value="{!test.cust_vendor__c}" />
</apex:outputPanel>
<apex:commandButton value="Tetete" onclick="openwindow();"/>
  </apex:pageBlockSection> 
</apex:form>
</apex:page>

And my popup page code is as below and I want to redirect top frame from inline page

<apex:page >

  <script>

  function test(){
     alert('hello');
     window.opener.top.location.href='https://googleflowauth-dev- ed.my.salesforce.com/001900000096agv';
  }

   </script>
   <apex:form >
    <!-- End Default Content REMOVE THIS -->
     <apex:commandButton onclick="test()" value="Test"/>
    </apex:form>

The error is pretty much I know that it is for security browsers dont allow

enter image description here

Unsafe JavaScript attempt to initiate navigation for frame with URL 'https://googleflowauth-dev-ed.my.salesforce.com/001900000096agv' from frame with URL 'https://googleflowauth-dev-ed--c.ap1.visual.force.com/apex/pagereal'. The frame attempting navigation is neither same-origin with the target, nor is it the target's parent or opener.

I am happy if i get workaround for same

share|improve this question
    
Have you tried to add a function in your inline page that executes window.parent.href=, and then in the popup execute window.opener.FUNCTIONNAME, rather than trying to refresh directly from the popup? –  Eric Aug 6 at 21:17
    
@Eric I can refresh the opener frame and then refresh parent.It works good but I want direct refresh to avoid flicker of inline page –  Mohith Shrivastava Aug 6 at 21:25
    
@Eric Please answer this .It worked finally :).You were right . –  Mohith Shrivastava Aug 6 at 21:45

2 Answers 2

up vote 3 down vote accepted
  1. add a function in your inline page that executes window.parent.href=

    function refreshParent(){ window.parent.href='URL'; }

  2. In the popup execute

    window.opener.refreshParent()

rather than trying to refresh directly from the popup?

share|improve this answer
    
Awesome thank you so much !!!! –  Mohith Shrivastava Aug 6 at 21:57

TO be be clear and precise the answer for this with sample code is below

<apex:page standardController="Account" extensions="Accountctrl">
<apex:form >
 <script>
  function openwindow(){
       window.open("/apex/pagereal", "myWindow", "width=200, height=100");
 }
  function navigate(){
  window.top.location.href='https://googleflowauth-dev-ed.my.salesforce.com/001900000096agv';//Parent function that redirects
  }
 </script>
<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:inputcheckbox>
<apex:outputPanel rendered="{!NOT(test.istest__c)}"> 
<apex:inputField value="{!test.Campaign__c}" />
<apex:inputField value="{!test.cust_vendor__c}" />
</apex:outputPanel>
   </apex:pageBlockSection> 
  </apex:pageBlock>

The code for popup will be as below

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

  <script>

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

 </script>
  <apex:form >
 <!-- End Default Content REMOVE THIS -->
  <apex:commandButton onclick="test()" value="Test"/>
  </apex:form>
</apex:page>

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.