2025年4月13日 星期日 乙巳(蛇)年 正月十四 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > Html+Div+Css(前端)

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

时间:10-26来源:作者:点击数:21

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中得写三个,根据自己需要进行改变!

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐