简体   繁体   English

JavaScript PopUp - 从Popup链接目标=其他浏览器窗口

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

i open a html page with a js popup 我打开一个带有js弹出窗口的html页面

<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. 不是我知道的...... 更正 :我认为你可以使用window.opener属性。

However, you may have better luck using something that loads the popup in the context of the current page using AJAX. 但是,使用AJAX可以更好地使用在当前页面的上下文中加载弹出窗口的东西。 In this case, since you're still on the main page, you have access to any javascript on that page. 在这种情况下,由于您仍然在主页面上,因此您可以访问该页面上的任何JavaScript。 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. 我使用Smoothbox完成了这项工作,Thickbox或其他人可以完成相同的任务。

You can also check out the opener property. 您还可以查看opener酒店。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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