iframe的当前网址 [英] Current url of iframe

查看:132
本文介绍了iframe的当前网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要获取iframe的当前网址(而不是iframe的第一个来源).如果iframe位于同一域中,则很容易,但iframe不会位于同一域中.另外,我不需要仅使用iframe,其他控件也可以为我工作.有什么想法吗?

感谢您的帮助.

Hi all,

I need to get the current url of iframe (not the first source of iframe). If iframe is in same domain, then it''s easy but iframe won''t be in same domain. Also, I don''t need to use only iframe anyother control will be work for me. Any ideas?

Thanks for your help.

推荐答案

这取决于您的IFrame的当前Url是否属于同一域.

如果集合的Url具有相同的Domain,则可以尝试下面的代码来获取它.
It depends Current Url of your IFrame is of the same Domain or not.

If the set Url is of the same Domain then you may try below code to get it.
var currentUrl = document.getElementById("MyIframeId").contentWindow.location.href;



但是,如果将其设置为其他域网址",例如"http://www.codeProject.com",那么我怀疑您将能够获得它.



But in case if it is set to some other Domain Url, For Example - "http://www.codeProject.com", then I doubt you will be able to get it.


这篇关于iframe的当前网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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