how to pass a new url from popup child window to the parent window?


I have  a parent window and a popup child window, in my child window I have a link to a new url (in a ahref block), if I click the link it should send that url to the parent window and focus the parent window, and close the popup child window. Any diea?, a simple sample code would be appreciated

Thanks in advance
Who is Participating?
cLFlaVAConnect With a Mentor Commented:
Your main page:

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<title> the main page </title>

<a href="#" onclick="'index1.html','my_win','height=300,width=300');">open popup</a>

Your Popup page:

<script language="javascript">
var popup_val = 10;

function RelocateAndClose(the_url) {
     opener.location = the_url;
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<a href="#" onclick="RelocateAndClose('');">Go To Google</a><br>
<a href="#" onclick="RelocateAndClose('');">Go To Yahoo!</a><br>
<A href="javascript:window.opener.location='';">Gooooogle</a>
Nice, but you'd still need the call to focus and close.

Why focus?  Just in case the user activated another window in the process.
javagiripAuthor Commented:
Thanks cLFlaVA, your approach works good!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.