zoukankan      html  css  js  c++  java
  • Iframe自适应高度

    正在踌躇的时候发现下面的这段代码,终于得意解决。苦于对js没有足够的熟悉,代码中的具体方法参数还得继续学习,感谢提供代码的朋友。
    function SetCwinHeight()
    {
    var cwin=document.getElementById("cwin");
    if (document.getElementById)
    {
    if (cwin && !window.opera)
    {
    if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
    cwin.height = cwin.contentDocument.body.offsetHeight;
    else if(cwin.Document && cwin.Document.body.scrollHeight)
    cwin.height = cwin.Document.body.scrollHeight;
    }
    }
    }

    <iframe width="778" align="center" height="200" id="cwin" name="cwin" onload="Javascript:SetCwinHeight(this)" frameborder="0" scrolling="no"></iframe>



    function SetCwinHeight(obj)
    {
      var cwin=obj;
      if (document.getElementById)
      {
        if (cwin && !window.opera)
        {
          if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
            cwin.height = cwin.contentDocument.body.offsetHeight;
          else if(cwin.Document && cwin.Document.body.scrollHeight)
            cwin.height = cwin.Document.body.scrollHeight;
        }
      }
    }

    引用时
    onload="javascript:SetCwinHeight(this)"

  • 相关阅读:
    第二章初识MySQL
    第一章 数据库
    Java&SQL7
    Java&SQL
    Java&SQL6
    Java&SQL5
    Java&SQL4
    Java&SQL3
    Java&SQL2
    博客地址已搬迁
  • 原文地址:https://www.cnblogs.com/zmc/p/3275627.html
Copyright © 2011-2022 走看看