Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to redirect a url from child window to its parent? 1

Status
Not open for further replies.

cyan01

Programmer
Mar 13, 2002
143
US
Hi, Experts,

I have some difficulties in javascript again. Here is what I want:

1) on one web page (call it parent window), under certain condition, a popup window (call it child window) will be poped up. -- This is done

2) There is a url link (e.g. on the newly popup window (call it child window). Once you click it, I want the parent window showing cnn's main page. But I don't know how.

Here is my partial code for the child window page:

Code:
<html>
<head>
<script type="text/javascript">
  function func1() 
  {
    window.open('/', '__new__');
    window.setTimeout("window.close()", 800);
  }
</script>
</head>
<body>
<a href="javascript:func1();"><img src="/images/abc.gif" width="444" height="75" alt="Click here to redirect"></a>
</body>
</html>

I know the problem is here
Code:
window.open('[URL unfurl="true"]http://www.cnn.com',[/URL] '_new_');

But I don't know what value I should use to substitute '_new_', so that the parent window will display cnn.com, once we click on link "Click here to redirect" on the child window? Please help. Many thanks!
 
Try this:

Code:
<a href="[URL unfurl="true"]http://www.cnn.com/"[/URL] target="window.opener"><img src="/images/abc.gif" width="444" height="75" alt="Click here to redirect"></a>

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Instead of
Code:
window.open('[URL unfurl="true"]http://www.cnn.com',[/URL] '_new_');
use
Code:
opener.location.href='[URL unfurl="true"]http://www.cnn.com';[/URL]

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top