2014年9月5日 星期五

iframe依內容自動調整框架高度



iframe.html

<iframe frameborder="0" src="source.htm" id="frameid" onload="javascript:reSize()"></iframe>

※參考來源的教學,直接使用只有Google Chrome可以運作,IE, FF不會動,因此要加上上述紅字的部分。

</script>(加在<head>....</head>之間

<script language="javascript">
function reSize(){
  //parent.document.all.frameid.height=document.body.scrollHeight;
  parent.document.getElementById("frameid").height=document.body.scrollHeight;
}
window.onload=reSize;
</script>
 


參考來源:http://www.minwt.com/js/112.html

沒有留言:

張貼留言