0
我有一个需要rezise它的高度在每次加载时的iframe,我想这样的例子很多,但他们都在IE和Chrome,但在Firefox中没有工作的罚款,直到我试图这样一个它适用于所有的东西的iframe属性的onload多次调用
function autoResize() {
var subscriptionFrame = jQuery("#frame_name_here");
var innerDoc = (subscriptionFrame.get(0).contentDocument) ? subscriptionFrame
.get(0).contentDocument
: subscriptionFrame.get(0).contentWindow.document;
if (innerDoc.body.scrollHeight == 0)
innerDoc.location.reload(true);
subscriptionFrame.height(innerDoc.body.scrollHeight + 10);
}
<iframe src="uploadFile.xhtml" class="upload-iframe"
id="frame_name_here" onload="autoResize();"></iframe>
但是有一个问题,这个脚本多次调用onload(递归),任何想法为什么?
由于改变高度触发负载 – Jacob 2014-08-28 09:30:44
是它因为这样:'innerDoc.location.reload(真);'? – Pete 2014-08-28 09:31:14
我想我找到了问题'如果(innerDoc.body.scrollHeight == 0) innerDoc.location.reload(真);'这部分使得它重新加载,但iframe的高度为0,直到一定的作用,但这个递归电话打电话给服务器任何想法如何阻止此? – 2014-08-28 09:38:25