简体   繁体   中英

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

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?

在弹出窗口中,将其添加到链接的onclick事件中:

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

You can also check out the opener property.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM