iframe自適應高度,以及一個頁面加載多個iframe


  <iframe id="iframepage" src="Index.html" name="iframepage" frameborder="0" width="1349" scrolling="no" onload="iFrameHeight()" ></iframe>

<a href="aboutUs.html" ; target="iframepage" >醫院介紹</a></li>
<a href="newsList.html" ; target="iframepage" >新聞動態</a></li>

  其中name  和  tatget   必須保持一樣。

  js中獲取iframe中頁面的高度

<script type="text/javascript">

function iFrameHeight() {
var ifm = document.getElementById("iframepage");
var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;      // IE和其他瀏覽器兼容選擇
if (ifm != null && subWeb != null) {
ifm.height = subWeb.body.offsetHeight;              //offsetHeight 頁面高度
}

}
</script>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM