iframe 在 div 中如何自適應高度

試了很多,只有這個起作用:

1.先在要使用iframe連結的頁面寫好iframe語法,id命名為frameid,注意scrolling不可以設定為no:
 <iframe src="test.htm" id="frameid" frameborder="0" onload="this.height=0;var fdh=(this.Document?this.Document.body.scrollHeight:this.contentDocument.body.offsetHeight);this.height=(fdh>700?fdh:700)">

 2.在要被連結的內容頁內,寫入以下語法:
 <head>
<script>
function resize(){ parent.document.getElementById("frameid").height=document.body.scrollHeight; }
</script>
</head>
<body onload="resize();">


[注意]
若iframe裡面div有用float排版的物件會讓iframe的高度抓不到

 解法:
 div.content 裡面有兩個block
一個靠右(float:right;)一個靠左(float:left;) 
這裡左右的兩個block 都要設定寬度之外,還要height:auto;
然後最外層的content要加上overflow:hidden;


參考資料來源:http://blog.xuite.net/jon6773/blog/17844864
                  http://zhidao.baidu.com/question/132932630.html
                  http://cabuchi.pixnet.net/blog/post/38762173-jq%EF%BD%9C%E5%8B%95%E6%85%8B%E8%A8%AD%E5%AE%9Aiframe%E9%AB%98%E5%BA%A6