【发布时间】:2014-12-08 22:43:47
【问题描述】:
您好,我正在尝试根据 iframe 的内容调整 iframe 的大小,但它无法正常工作可能是因为跨域
这是我正在使用的代码
<script language="javascript" type="text/javascript">
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
<iframe src="http://other_domain_name/get?v=07armilCx5A" frameborder="0" scrolling="no" id="iframe" width="100%" height="300px" onload="javascript:resizeIframe(this);"></iframe>
请帮助我如何解决这个问题以从其他域中获取 iframe 中的页面
【问题讨论】:
-
检查resizeIframe函数中contentWindow的值。
-
对于跨域消息传递,您可以使用 easyXDM
-
您没有访问嵌入内容中的任何内容,我认为这里不可能存在跨域问题。
-
但嵌入后无法正常工作,无法加载完整页面
标签: javascript jquery html css iframe