+ Start a Discussion
paul-lmipaul-lmi 

Weird issue when launching VF via onClick javascript for standard layout link

I'm running into a weird issue here. When I pop a new window using a button's onclick javascript option, like window.open("myVFpage","page"); , the page cannot reference the parent window. Is this because the parent is on a separate domain (because VF doesn't run on the same domain as the standard SF layout)? What I'm trying to do, is pop a new window which is a VF page, do some stuff, and on close of the popup, refresh the window that launched the popup.

 

When I try this

 

<apex:page standardController="Case" extensions="CaseAddContactCon" showHeader="false" sidebar="false" tabStyle="Case" id="page">
<script type="text/javascript">
function closeandreload(){	
	try{
		if (window.opener && !window.opener.closed) {
			window.opener.location.reload();
		}
	}catch(err){	
	}
	window.close();
}
</script>
<apex:pageBlock id="pageBlock">
<apex:form id="form">
	<apex:inputField id="txtSuppliedName" value="{!case.SuppliedName}" />
	<apex:inputField id="txtSuppliedEmail" value="{!case.SuppliedEmail}" />
	<apex:commandButton id="btnCreate" action="{!AddContactInfo}" status="status" oncomplete="closeandreload()" value="Create Contact"/>
</apex:form>
</apex:pageBlock>
<apex:actionstatus id="status" onstart="Working..." onstop="" />
</apex:page>

 

The part that is supposed to reload the window.opener window fails in every browser.

 

_Prasu__Prasu_

Does Parent window contains Salesforce standard page or any VFPage.

 

If its a standard page then you will not be able to refresh it. If its VisualForce page then you should be able to refresh the parent window page

paul-lmipaul-lmi

is there a way I could work around this limitation other than overriding the standard detail view?  The only reason I even need to use VF is because you can't view the SuppliedEmail and SuppliedName fields on Case unless theya re already populated.

Pradeep_NavatarPradeep_Navatar

Use "window.parent.location.replace('/{!$CurrentPage.parameters.id}');" to refresh a standard page and use "window.parent.location.reload(true);" to refresh a visualforce page.