0
我正在嘗試調整iframe的大小。我的代碼在Chrome和Interner Explorer中工作,但不在Firefox中。有人可以解釋爲什麼。調整iframe的大小,而不是在Firefox中工作
這裏是我的javascript:
<script type="text/javascript" language="javascript">
function autoResize(id){
var newheight;
if(document.getElementById){
newheight=document.getElementById(id).contentDocument .body.scrollHeight;
}
document.getElementById(id).height= newheight;
}
</script>
這裏是我的iframe:
<iframe id="myframe" src="http://www.somesite.com/content/index.php" frameborder="0" scrolling="no" width="900px" onLoad="autoResize('myframe');"></iframe>
你在這裏有什麼錯誤嗎?在這裏給出一個警告,看看你是否真的在Firefox中獲得高度。 –
www.somesite.com是否與你的腳本同源?網頁處於怪異模式或標準模式下的子幀中? –