有什么办法可以在父窗口中获取弹出窗口的网址 [英] Is There Any Way We Can Get Url Of PopUp Windows In Parent Window

查看:90
本文介绍了有什么办法可以在父窗口中获取弹出窗口的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取弹出窗口的网址,并在父"窗口中显示它.

I want to Get a url of popUp window And Show It in Parent window.

<a href="#" onClick="MyWindow=window.open('http://www.google.com','MyWindow',width=600,height=300); return false;">Click Here</a>

我想在父窗口中显示popurl,即google.com.

I Want to show popurl i.e google.com in parent window.

推荐答案

如果弹出窗口来自第三方域(例如google.com),则由于以下原因,您无法访问弹出窗口的location.href属性原产地政策".

If the popup is from a third party domain (such as google.com), then you can't access the location.href property of the popup because of the "same origin policy".

如果它在同一个域中,则可以通过在父窗口中执行以下操作来获取URL:

If it's in the same domain, then you can get the URL by doing this on the parent window:

popUpWindow.location.href

这篇关于有什么办法可以在父窗口中获取弹出窗口的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆