Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

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

Hi,

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
0
javagirip
Asked:
javagirip
  • 2
1 Solution
 
cLFlaVACommented:
Your main page:

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

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



Your Popup page:


<html>
<head>
<script language="javascript">
<!--
var popup_val = 10;

function RelocateAndClose(the_url) {
     opener.location = the_url;
       opener.focus();
       window.close();
}
-->
</script>
<title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<a href="#" onclick="RelocateAndClose('http://www.google.com/');">Go To Google</a><br>
<a href="#" onclick="RelocateAndClose('http://www.yahoo.com/');">Go To Yahoo!</a><br>
<br><br><br>
</body>
</html>
0
 
arantiusCommented:
<A href="javascript:window.opener.location='http://www.google.com/';">Gooooogle</a>
0
 
cLFlaVACommented:
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.
0
 
javagiripAuthor Commented:
Thanks cLFlaVA, your approach works good!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now