Solved

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

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Suggested Courses

636 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