How can I get the URL
of an iframe that load a page in other site (CORS)?
如何获取在其他站点(CORS)中加载页面的iframe的URL?
iFrameObject.contentWindow.location.href
returns CORS Error
返回CORS错误
UPDATE:
更新:
The user will navigate inside the iframe and will get another url that I didn't know. This is what I want to check, if the user gets to that url, the iframe close itself.
用户将在iframe内导航,并将获得另一个我不知道的网址。这就是我要检查的内容,如果用户访问该网址,则iframe会自行关闭。
Related question: How to get data from an external site inside a cordova application? (I'm trying to get the information in the paramters of the url)
相关问题:如何从cordova应用程序内的外部站点获取数据? (我试图在网址的参数中获取信息)
1 个解决方案
#1
2
You can simply get it's src
property:
你可以简单地得到它的src属性:
var URL = iFrameObject.src;
// something like "http://example.com"
UPDATE: Since that the URL of the frame will change and become different from the src
property, you'll not be able to access it without violating the Cross-Origin policy. You cannot perform any action in an iframe
that has got another origin.
更新:由于框架的URL将更改并与src属性不同,因此您将无法在不违反跨源策略的情况下访问它。您无法在具有其他来源的iframe中执行任何操作。
#1
2
You can simply get it's src
property:
你可以简单地得到它的src属性:
var URL = iFrameObject.src;
// something like "http://example.com"
UPDATE: Since that the URL of the frame will change and become different from the src
property, you'll not be able to access it without violating the Cross-Origin policy. You cannot perform any action in an iframe
that has got another origin.
更新:由于框架的URL将更改并与src属性不同,因此您将无法在不违反跨源策略的情况下访问它。您无法在具有其他来源的iframe中执行任何操作。