function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gattam Rakesh (SFDC)Gattam Rakesh (SFDC) 

How to popup a Vf Page From a Vf Page

Hai all
          can any one explain me how to populate a vf page from a vf page for example i have two pages page1 and page2 in page1 we will be having one button open Page2 by clicking that page2 should populate in page1 
 Thanks in advance
sandeep sankhlasandeep sankhla
Hi Gattam,

You can simply call one java script function onclick of your button and then you can use below code to open your VF page as popup there
function openPopup()
			{'/apex/ContactListPage?id={!sObjectId}', '_blank','left=300 top=100 width=660 height=550 scrollbars=yes resizable=yes');

Please implement the above and let me know if that works for you..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Salesforce Certified Developer 
Try the below code in your Visualforce page
function OpenPopWindow(){
 window.showModalDialog("/apex/VFPage","dialogWidth:800px; dialogHeight:200px; center:yes");

<apex:commandButton value="Popup VF Example" onclick="OpenPopWindow();"/>

Anupam RastogiAnupam Rastogi
Hi Gattam,

As I understand, you wish to open Page2 within Page1 and not in a new window, on the click of a button. So to achieve this you can use the following VF Page scripts.

These are working test scripts. You just need to create two pages and one class with the contents.

Page 1 that has the button to include the following code - 
<apex:page controller="ExampleController">
    This is the Parent Page that has the button to include the Child Page within this page itself.
    <apex:form >
        <apex:outputpanel id="shownewpage">
            <apex:commandButton action="{!ShowPage}" value="Open Child Page" />
            <apex:include pageName="EmbedAnother" rendered="{! IF(ShowPage == True, True, False) }"/>            
            <apex:actionSupport event="onclick" 

ExampleController class used by Page 1 to include the following code - 
public class ExampleController {

    Boolean ShowPage = False;
    public PageReference ShowPage() {
            ShowPage = True;
            return null;

    public Boolean getShowPage() {
        return ShowPage;

Page 2 includes anything you wish to display. Like
<apex:page >
    This is the Child Page.


If you find this reply useful that solves your query then please mark it as best to benefit others.