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)"

  • 相关阅读:
    文件的类型
    读取文件,并按原格式输出文件内容的三种方式
    react hook代码框架
    器具的行为模式
    设计模式
    cpu 内存 机器语言 汇编 高级语言 平台之间的关系
    操作系统之内存
    操作系统之文件
    操作系统之IO
    七层模型之应用层
  • 原文地址:https://www.cnblogs.com/zmc/p/3275627.html
Copyright © 2011-2022 走看看