【问题标题】:Url of the loaded html in an IframeIframe 中加载的 html 的 URL
【发布时间】:2011-01-28 01:10:06
【问题描述】:

我们有一个外部托管的客户门户网站。 我需要在我们公司网站上创建一个页面,员工将使用该页面登录门户。他们提供的登录页面是通用的

为了实现这一点,我计划创建一个页面,然后创建 iframe(宽度:200 像素;高度:100 像素)客户门户的登录页面。这样我就可以在登录页面上显示公司品牌..

但我的问题是,当用户通过 iframe 登录时,生成的主页会在 iframe 窗口中打开。

我的问题:有没有办法找到加载到 iframe 中的页面的 url,以便根据 url,我可以更改 iframe 的尺寸?

iframe 的 src 属性总是显示登录页面 url。

我的 iframe 代码:

<iframe onload="loadMyFrame();"  src ="https://login.tomyportal.com" width ="370" height="200" id="sWindow" frameborder="0"></iframe> 
<script type="text/javascript" language="javascript">
 function loadTest() {
  var ifr = document.getElementById("sfWindow");
  alert(ifr.src); //the value returned is always login page.
 }
</script>

【问题讨论】:

    标签: iframe


    【解决方案1】:

    怎么样

    alert(ifr.location.href)
    

    ?

    【讨论】:

      猜你喜欢
      • 2021-03-28
      • 2012-05-03
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 2017-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多