Activity › Forums › Salesforce® Discussions › How to call a parent window function in a child window in a salesforce VisualForce page?
-
How to call a parent window function in a child window in a salesforce VisualForce page?
Posted by sushant on January 24, 2017 at 1:18 PMHi All,
How to call parent a window function in a child window in VisualForce page?
Thanks
Vikas Kumar replied 9 years, 3 months ago 2 Members · 1 Reply -
1 Reply
-
Hi sushant,
you can try something like this
VF page
<apex:page controller=”LookupMainController”>
<apex:form >
<apex:pageBlock title=”Lookup”>
<apex:pageBlockSection columns=”1″>
<apex:pageBlockSectionitem >
<apex:outputLabel value=”Account”/>
<apex:outputPanel >
<apex:inputHidden value=”{!accountId}” id=”targetId” />
<apex:inputText size=”40″ value=”{!accountName}” id=”targetName” onFocus=”this.blur()” disabled=”false”/> <a href=”#” onclick=”openLookupPopup(‘{!$Component.targetName}’, ‘{!$Component.targetId}’); return false”>Lookup</a>
</apex:outputPanel>
</apex:pageBlockSectionitem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionitem >
<apex:commandButton value=”Get Contacts” action=”{!findContacts}”/>
</apex:pageBlockSectionitem></apex:pageBlockSection>
</apex:pageBlock>
<script>
var newWin=null;
function openLookupPopup(name, id)
{
var url=”/apex/LookupExamplePopup?namefield=” + name + “&idfield=” + id;
newWin=window.open(url, ‘Popup’,’height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no’);
if (window.focus)
{
newWin.focus();
}return false;
}function closeLookupPopup()
{
if (null!=newWin)
{
newWin.close();
}
}
function fillIn(name, id)
{
var winMain=window.open(“https://vikas1st-dev-ed–vikasapp.ap2.visual.force.com/”+id);
}
</script>
</apex:form>
<apex:pageBlock >
<apex:pageBlockSection ><apex:pageBlockTable value=”{!contacts}” var=”contact”>
<apex:column headerValue=”LastName”>
<apex:outputLink value=”#” onclick=”fillIn(‘{!contact.LastName}’, ‘{!contact.id}’)”>{!contact.LastName}</apex:outputLink>
</apex:column>
<apex:column headerValue=”FirstName” value=”{!contact.LastName}”/></apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Log In to reply.