【发布时间】: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>
这适用于任何内部页面(来自同一域的页面)。我正在努力让它与外部页面(跨域)一起工作,但没有找到任何解决方案。
似乎不可能进行我真的没想到的跨域通信。无论如何,谢谢大家。
【问题讨论】:
-
我知道 contentWindow.document 负责调用内部页面。但是我应该用什么来调用外部?
-
您不能在您的域上“加载”跨域页面。了解 XSS。
-
@ 不管它是什么,它只是没有工作
标签: javascript jquery iframe