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>

原文地址:https://www.cnblogs.com/liuyubin0629/p/7819004.html