从iFrame中检索完整的URL

时间:2011-02-05 01:36:30

标签: javascript jquery iframe href

  

可能重复:
  How do I get the current location of an iframe?

您好我想获得完整的网址,并且我知道的方法我得到的是完整的网址但是iframe,我想要'final'document.location.href,

我怎么能得到它?

我不在乎它的php或js,但我猜测我的实验用PHp是不可能的......

2 个答案:

答案 0 :(得分:1)

如果您想知道当前的位置:

  • 客户端 - javascript - 您可以使用alert(window.location)
  • 服务器端 - php - .$_SERVER["REQUEST_URI"]$_SERVER['PATH_INFO'],具体取决于您的需求。

答案 1 :(得分:0)

查看top answer from this question

重要的是要注意,如果iframe的URL来自与父页面不同的域,那么(幸运的是!)无法获取iframe的URL。如果你想这样做,你可能会运气不好。