解决iframe出现两个滚动条的问题

来源:互联网 发布:听相声小品软件 编辑:程序博客网 时间:2024/04/29 14:08
花了一个多小时,终于解决了因为iframe框架出现两个滚动条的问题。原理( 借鉴了网上kaka的思路,但是js与他写的不一样)是:
1.强制隐藏最上层窗口的滚动条
2.获取浏览器窗口的高度
3.用浏览器窗口的高度减去头部iframe的高度就是内容iframe的高度了
       
<head>
    <title>main</title>
    <script type="text/javascript" src="<c:url value='/adminjsps/js/jquery-1.7.2.min.js'/>"></script>
    <script type="text/javascript">
    $(function(){
    var ht = $(window).height();//获取浏览器窗口的整体高度;
   var top = $("#top").height();//获取头部高度,定义一个变量名为topHeader
   var btop = ht - top;// 计算bottom的高度
   $("#tree").css("height",btop);
   $("#body").css("height",btop);
    });
</script>
    <style type="text/css">
    *{margin:0; padding:0; font-family:'微软雅黑';}
    html{overflow:hidden;}/*强制去掉主页面的滚动条*/
    .cont{width:100%; height: 100%; over-flow:hidden;}
    iframe{width:100%; height:100%;}
    .top{width:100%; height:78px; }
    .bottom{width:100%;  float:left;}
    .bottom .tree{width:16%; height: 100%;   over-flow:hidden; float:left; margin-left:1%;}
    .bottom .body {width: 80%;  height: 100%; float:left;  margin-left:1%; }
    </style>
  </head>
  <body>
    <div class="cont">
    <div class="top">
    <iframe frameborder="0" src="<c:url value='/adminjsps/jsps/header/header.jsp'/>" name="top" id="top"></iframe>
    </div>
    <div class="bottom">
    <div class="tree">
    <iframe frameborder="0" src="<c:url value='/adminjsps/jsps/left/left.jsp'/>" name="tree" id="tree"></iframe>
    </div>
    <div class="body">
    <iframe frameborder="0" src="<c:url value='/adminjsps/jsps/bodysample.jsp'/>" name="body" id="body"></iframe>
    </div>
    </div>
    </div>
  </body> 
0 0
原创粉丝点击