Solved

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

Posted on 2004-09-14
4
189 Views
Last Modified: 2008-03-03
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
Comment
Question by:javagirip
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
cLFlaVA earned 50 total points
ID: 12059225
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
 
LVL 18

Expert Comment

by:arantius
ID: 12059247
<A href="javascript:window.opener.location='http://www.google.com/';">Gooooogle</a>
0
 
LVL 13

Expert Comment

by:cLFlaVA
ID: 12059257
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
 

Author Comment

by:javagirip
ID: 12059356
Thanks cLFlaVA, your approach works good!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now