I have a requirement of passing the Id of the parent page to the pop-up form, so that when a user clicks the 'CANCEL' button on the pop-up the control gets transferred back to the parent page.

For this, I need to have the Id of the original page in context. This page has a custom button which when clicked opens up a pop-up.

Any help is appreciated.

Here is the code that opens up a pop-up...


function requireCssFile(filename) 
var fileref = document.createElement('link'); 
fileref.setAttribute('rel', 'stylesheet'); 
fileref.setAttribute('type', 'text/css'); 
fileref.setAttribute('href', filename); 

var j$ = jQuery.noConflict(); 
var iframe_url = '{!URLFOR("/apex/Add_address")}'; 

var j$modalDialog = j$('<div id="opppopup"></div>') 
.html('<iframe id="iframeContentId" src="' + iframe_url + '" frameborder="0" height="100%" width="100%" marginheight="0" marginwidth="0" scrolling="no" />') 
autoOpen: false, 
title: 'Add Details', 
resizable: true, 
width: 800, 
height: 540, 
autoResize: true, 
modal: true, 
draggable: true 


Here is the VF page:

    <apex:outputPanel id="tstpopup">

         <apex:pageBlockSection >
         <apex:pageblockSectionItem >
            <apex:outputlabel for="Address_Line1">
            Address Line 1
            <apex:panelGroup >

            <apex:inputtext id="Address_Line1" value="{!AddrLine1}" required="true"/>

                            <apex:pageBlockSection >
         <apex:pageblockSectionItem >
            <apex:outputlabel for="Country">
            <apex:panelGroup >

            <apex:inputText id="Country" value="{!Country}" required="true"/>


            <apex:commandButton value="Cancel" action="{!closePopup}" onclick="window.close();">

            <apex:commandButton value="Save" action="{!save}" rerender="abcd">



The user after entering Address Line 1 and the country fields can either click CANCEL or SAVE buttons.

  • Are you talking about the html id?
    – highfive
    Jul 16, 2014 at 9:28
  • I am talking about the default salesforce Ids
    – juhi
    Jul 16, 2014 at 9:32
  • Is your popup also another visualforce page?
    – highfive
    Jul 16, 2014 at 9:37
  • the pop-up is a javascript that calls a visualforce page
    – juhi
    Jul 16, 2014 at 9:42
  • So at the place where you call the popup link, add the id as a query string and use it in the popup. Can you edit the question and add the code where you call the popup
    – highfive
    Jul 16, 2014 at 9:43

1 Answer 1


You can pass values by using the query string.

var iframe_url = '{!URLFOR(/apex/Add_address?parent_id=your_parent_page_id)}'; 

And then in the popup page controller constructor, grab the id like below

String ppId = System.currentPageReference().getParameters().get('parent_id');
  • I tried this..But because the pop-up opens on the same page so the redirecting to the parent page does not happen
    – juhi
    Jul 16, 2014 at 12:04
  • What you mean by redirecting here?if it's a popup, just closing the popup(may be upon clicking cancel as you have mentioned) user will automatically land into the parent page right?btw,this answer is for your question "how to pass is to popup page"
    – highfive
    Jul 16, 2014 at 13:30
  • When the user clicks on 'Cancel' nothing is happening as of now. :( i want to redirect to the page on which the button was originally clicked to open the popup.
    – juhi
    Jul 16, 2014 at 13:34
  • if you need to close the popup and let user land into the parent page, add top.close(); into the onclick event of your cancel button. No need to purposely redirect.
    – highfive
    Jul 16, 2014 at 14:28
  • top.close() isn't working...
    – juhi
    Jul 16, 2014 at 19:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .