Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-09-14
4
Medium Priority
?
196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
cLFlaVA earned 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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 demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

715 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