0
我已經研究過這個,但是大多數人似乎都遇到了相反的問題,因爲他們的解決方案是使用我已經應用的代碼。我正在根據內容動態調整我的iFrame的尺寸,並且它在Chrome和FF中像一個魅力。 IE不起作用。代碼如下。謝謝。iFrame高度在IE中不能正確返回
function resizeIframe(iframe) {
iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
/*
iframe.height = "500px" - this worked fine in all browsers
*/
}
<iframe id="exampleIframe" onload="resizeIframe(this);" />
答案編輯成包括+ "px"
,現在該功能在Chrome & FF,但仍然沒有IE瀏覽器。
您是否嘗試過使用['setAttribute()'](https://developer.mozilla.org/en/docs/Web/API/Element/setAttribute)? –
'iframe.setAttribute(「height」,iframe.contentWindow.document.body.scrollHeight +「px」);' 同樣的情況;在Chrome中運行,在FF/IE中沒有運氣。 – Santi
iframe src是否來自同一個域? ...如果不是,那麼回答這個問題,你碰到了交叉原點塊。 – LGSon