Solved

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

Posted on 2004-09-14
4
191 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

831 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