zoukankan      html  css  js  c++  java
  • 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);}

    }

  • 相关阅读:
    内存溢出和内存泄漏的区别
    测试管理三要素(人员、过程和技术)
    面试可提问的6个问题
    弱网测试(二)
    js捕获错误
    TortoiseGit自动记住用户名密码的方法
    win7 "com surrogate“ 已停止工作的解决办法
    仿百度图片毛玻璃效果
    毛玻璃效果
    vimium快捷键列表
  • 原文地址:https://www.cnblogs.com/xsmhero/p/1860550.html
Copyright © 2011-2022 走看看