最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

JavaScript PopUp - Link target from Popup = other Window of browser - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question asked Nov 30, 2009 at 19:00 SurfingCatSurfingCat 1514 gold badges5 silver badges12 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

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

window.opener.location.href = "link_in_old_window.htm";

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 acplish the same task.

You can also check out the opener property.

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

发布评论

评论列表(0)

  1. 暂无评论