• body 适应ifram 高度


    <!--Iframe自适应其加载的内容高度-->
    <script type="text/javascript">
         function iframeAutoFit()
         {
            try
            {
               if(window!=parent)
               {
                var a = parent.document.getElementsByTagName("IFRAME");
                  for(var i=0; i<a.length; i++) //author:meizz
                  {
                     if(a[i].contentWindow==window)
                     {
                         var h = document.body.scrollHeight;
                         if(document.all) {h += 4;}
                         if(window.opera) {h += 1;}
                         a[i].style.height = h;
                     }
                  }
               }
            }
            catch (ex)
            {
               alert("脚本无法跨域操作!");
            }
         }
         if(document.attachEvent)    window.attachEvent("onload",    iframeAutoFit); 
         else    window.addEventListener('load',    iframeAutoFit,    false); 
    </script> 

    function my_init()
    {

    minHeight = document.getElementById("listWindow").offsetHeight;
    minWidth = document.getElementById("listWindow").offsetWidth;

    }

    function resizeHeight(h, w)
    {
        h += 40;
    //    if (w) {w += 20;}
        if (h>minHeight) {document.all.listWindow.style.height = h;}
        if (w && w>minWidth) {document.all.listWindow.style.width = w;}
    //    if (parent && parent.resizeHeight) {parent.resizeHeight(document.body.scrollHeight);}
    }

    ifram 页面

    function my_init()
    {

    if (parent && parent.resizeHeight) {parent.resizeHeight(document.body.scrollHeight);}

    }

  • 相关阅读:
    Java中ArrayList和LinkedList区别
    poi操作excel之: 将NUMERIC转换成TEXT
    Spring事务异常回滚,捕获异常不抛出就不会回滚
    CollectionUtils.select用法
    名词解释
    jenkins
    代码测试文章推荐
    redis 参考文章
    zookeeper,dubbo,dubbo admin
    Navicat For Mysql快捷键
  • 原文地址:https://www.cnblogs.com/xsmhero/p/1860550.html
Copyright © 2020-2023  润新知