a coder
a coder

Reputation: 7639

Close pop-up then go to a URL in the parent

I've opened a popup with:

window.open(url, 'mySurvey', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,dependent,width=1000, height=800,left=50,top=50');

When that window is open the user can click a link that will close the window, then redirect to a page in the parent window.

I'm familiar with window.close() and that works OK. I'm unsure how to get a redirect action in the parent window with the same click action.

Upvotes: 1

Views: 53

Answers (1)

Racil Hilan
Racil Hilan

Reputation: 25351

You can access the window that opened the popup using window.opener or window.parent. You can use that in your click event before closing the popup:

function myClickEvent(){
    window.opener.location.href = "the_new_url.htm";
    //or window.parent.location.href = "the_new_url.htm";
    window.close();
}

Upvotes: 1

Related Questions