+ Start a Discussion

Refresh parent window when pop up window closes



I'm attaching a custom button to the account page that opens a new window which is Visual Force.  I want the user to enter in information, click a submit button, and then update the account and refresh the account page.  Is there anyway I can do this?


I've tried some Javascript but I get a  permission denied error.

Rajesh ShahRajesh Shah

You can try the following code in your javascript code:



window.opener.location.href = url; window.close();


If you still get the error of permission denied, then it maybe because your visaulforce page resides on a different server than the detail page of Account.



Salesforce does something similar when you delete a custom field, maybe worth taking a look under the hood on those pages.




If you were launching your window from a VF page then this would launch the popup (custom note field on account)

<script> var newWin=null; function openPopup(url) { newWin=window.open(url, 'Popup','height=600,width=500,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,status=no'); newWin.focus(); return false; } </script> <apex:outputLink id="notesLink" onclick="openPopup('NotesView?id={!account.id}');return false;" value="Popup">"{!account.Latest_Note__c}" <apex:param name="id" value="{!account.id}"/> </apex:outputLink>


I've tried using Rajesh's example but it gives the same error. I think the problem is due to the vf page and the original account page coming from two different domains. 
Rajesh ShahRajesh Shah
If you are trying to refresh the window, I would instead try to redirect the user to account page again in the parent window i.e. window.parent.location.href = "/" + accoutId;



This is bang on.  Standard salesforce pages are hosted by salesforce.com and visualforce pages are hosted on visual.force.com.  


If standard salesforce opens a visualforce page, the visualforce page cannot control the parent page in any way (cross-site scripting block).


What would be nice is if salesforce allowed us to force pages to be hosted on the same domains.  Salesforce???  Anyone there???


But by it works fine in other browsers, cant we say IE problem rather than domain ?