【问题标题】:Is there any way to get external pagess via JavaScript on iframe? [duplicate]有没有办法通过 iframe 上的 JavaScript 获取外部页面? [复制]
【发布时间】:2015-01-15 07:01:00
【问题描述】:

我能够使用这个成功加载全宽的内部页面

<script type="text/javascript">
     function calcHeight()
     {
     //find the height of the internal page
     var the_height=
     document.getElementById('the_iframe').contentWindow.
     document.body.scrollHeight;

     //change the height of the iframe
     document.getElementById('the_iframe').height=
     the_height;
     }
</script>

<iframe width="100%" src="/mypage.php" 
scrolling="no" id="the_iframe" onLoad="calcHeight();" height="1px" frameborder="0" ></iframe>

这适用于任何内部页面(来自同一域的页面)。我正在努力让它与外部页面(跨域)一起工作,但没有找到任何解决方案。

似乎不可能进行我真的没想到的跨域通信。无论如何,谢谢大家。

【问题讨论】:

标签: javascript jquery iframe


【解决方案1】:

无法访问引用跨域 url 的 iframe 的内容。

【讨论】:

    猜你喜欢
    • 2013-08-21
    • 2012-01-16
    • 1970-01-01
    • 2012-11-02
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 2021-12-10
    • 2012-05-18
    相关资源
    最近更新 更多