views:

558

answers:

3

Hello, i open a html page with a js popup

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
    newwindow=window.open(url,'foobar','height=575,width=950');
    if (window.focus) {newwindow.focus()}
    return false;
}

// -->
</script>

<a href="index.php" onclick="return popitup('foobar.html')">Link to popup</a>

Now I got some Links in my Popup and I want to close the Popup onclick of my link AND OPEN LINK IN THE OLD WINDOW. With old window I mean the browser window who calls the popup. Is this possible?

A: 

Not that I know of... CORRECTION: I think you can use the window.opener property.

However, you may have better luck using something that loads the popup in the context of the current page using AJAX. In this case, since you're still on the main page, you have access to any javascript on that page. So for example, you can popup a window, capture the click event without that window, close the popup window dynamically, and then change the current page location.

I've done this using Smoothbox but Thickbox or others can accomplish the same task.

Andrew Flanagan
I think this is much better buuuuutttt... i used http://jquery.com/demo/thickbox/ thickbox with iframes and there is the same... it opens the links in the iframe
SurfingCat
+2  A: 

In the popup, add this to the onclick event of your link:

window.opener.location.href = "link_in_old_window.htm";
Pekka
THANKS, but i need to use target"_parent" =) But works perfect! THANKS
SurfingCat
A: 

You can also check out the opener property.

http://www.webreference.com/js/tutorial1/opener.html

Nate B