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