ie7中iframe高度100%无效的解决办法

100%高度的iframe在ie7中显示错误,原因是iframe.style.height="100%"。

 在网上搜到很多iframe自适应高度的文章。我们只需要让iframe的高度跟浏览器显示区域的高度一样就行了,跟iframe自适应高度是不一样的。

下面使用js实现iframe中的高度和浏览器的高度一样。

<script type="text/javascript">
        function htmlH() {
            document.getElementById("menu").style.height = screen.availHeight;
            document.getElementById("iframe1").style.height = screen.availHeight;
            document.getElementById("right").style.height = screen.availHeight;
       }
    </script>
   </head>
<body style="margin-top:1px; margin-left:0px; margin-bottom:1px;" οnlοad="htmlH()">
    <form id="form1" runat="server" >
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <iframe id="menu" name="menu" src="menu.aspx" width="13%" frameborder="0" marginheight="0"></iframe>
                <iframe id="Iframe1" src="b.aspx" width="4px" frameborder="0" marginheight="0" style="" scrolling="no"></iframe>
                <iframe id="right" name="R1" src="index.aspx" width="86.5%"  frameborder="0" marginheight="1"  marginwidth="1" runat="server" style="margin:0;"></iframe>
                <br />
            </ContentTemplate>
    
        </asp:UpdatePanel>
   
    </div>
    </form>
</body>
</html>

本文有三个iframe,所以在js中得写三个,根据自己需要进行改变!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值