Saeid
Saeid

Reputation: 2036

Opening a new pop up window from another pop up window using javascript

I want to open a pop up from another pop up and i used below code, but when i click the pop up refresh and the items appear in it instead of another pop up.

I want to show two popup, but only one pop's up. Can anybody helps me?

The code:

function pop_up(url) {
    newwindow = window.open(url,
        'name',
        'height=517,width=885,scrollbars=yes,toolbar=no,menubar=no,resizable=yes,location=no,directories=no,status=no,titlebar=no,left=400,top=120');
    if (window.focus) { newwindow.focus() }
    return false;
}

Click event code:

Page.ClientScript.RegisterStartupScript(GetType(), "popup",
    "pop_up_Info('" + "PopUpEmailing.aspx" + "');", true);

Upvotes: 3

Views: 5525

Answers (2)

Kelsey
Kelsey

Reputation: 47726

Modify your control pop_up function:

function pop_up(url, windowName) {
    newwindow = window.open(url, 
        windowName,
        'height=517,width=885,scrollbars=yes,toolbar=no,menubar=no,resizable=yes,location=no,directories=no,status=no,titlebar=no,left=400,top=120');
    if (window.focus) { newwindow.focus() }
    return false;
}

Then in your call registered call do:

 Page.ClientScript.RegisterStartupScript(GetType(),
     "popup", "pop_up('PopUpEmailing.aspx', 'PopUpEmailing');", true);

Make sure the second param is different name from the window that called the original popup.

Upvotes: 1

Marcus Vinicius
Marcus Vinicius

Reputation: 1908

Similar question was answered here.

You have to specify a new name for the window in the window.open method.

Upvotes: 2

Related Questions