码迷,mamicode.com
首页 > 其他好文 > 详细

iframe 使用,及其高度自定

时间:2017-11-11 15:26:56      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:javascrip   浏览器兼容   bsp   dex   nload   ntb   function   页面   兼容   

<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>

 

iframe 使用,及其高度自定

标签:javascrip   浏览器兼容   bsp   dex   nload   ntb   function   页面   兼容   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!