zoukankan      html  css  js  c++  java
  • 兼容IE和FireFox的iframe 自动高度脚本

    iframe name="mainframe" id="mainframe" src="" onload="this.height =document.frames['mainframe'].document.body.scrollHeight" border="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width="732"></iframe>这种方法只能在ie上面有用,在firefox中并不支持,因此我做了一个兼容IE和FireFox的iframe 自动高度脚本和大家分享!

    <html>
    <head>
    <title>兼容IE和FireFox的iframe 自动高度脚本</title>
    <link href="/zbh/css/style.css" rel="stylesheet" type="text/css" />
    <link rel="Shortcut Icon" href="/share/pic/logo.ico">
    <link rel="Bookmark" href="/share/pic/logo.ico">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    </head>

    <script> 

    var FFextraHeight = 0;
     if(window.navigator.userAgent.indexOf("Firefox")>=1)
     {
      FFextraHeight = 16;
      }
     function ReSizeiFrame(iframe)
     {
       if(iframe && !window.opera)
       {
         iframe.style.display = "block";
          if(iframe.contentDocument && iframe.contentDocument.body.offsetHeight)
          {
            iframe.height = iframe.contentDocument.body.offsetHeight + FFextraHeight;
          }
          else if (iframe.Document && iframe.Document.body.scrollHeight)
          {
            iframe.height = iframe.Document.body.scrollHeight;
            alert(iframe.Document.body.scrollHeight);
          }
       }
     }

    </script>

    <iframe name="mainframe" id="mainframe" src="/share/aa.html" onload="ReSizeiFrame(this)" border="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width="732"></iframe>
        
     </body>

    </html>

  • 相关阅读:
    MySQL语句创建表、插入数据遇到的问题-20/4/18
    【Navicat】MySQL 8.0.17 数据库报2059错误
    MySQL 8.0.17 版安装 || Windows
    C#--Invoke和BeginInvoke用法和区别
    C#--params关键字
    C#--typeof() 和 GetType()区别
    C#--利用反射编写的SqlHelper类
    C#--反射基础
    C#--LINQ--2--LINQ高级查询
    C#--LINQ--1--初学LINQ基础和查询
  • 原文地址:https://www.cnblogs.com/hpuCode/p/2716377.html
Copyright © 2011-2022 走看看