zoukankan      html  css  js  c++  java
  • iframe框架高度随内容的变化而变化的代码

    <iframe src="XXX.htm" width="700px" frameborder="0" id="frmsrc" scrolling="no" marginheight="0" onload="AutoIframe()"></iframe>

    <script type="text/javascript">
        function AutoIframe()
        {
            if(document.readyState!='complete')
            {
                setTimeout( function(){AutoIframe();},25 );
                return;
            }
            else
            {
               var ifobj=document.getElementById("frmsrc");
               ifobj.height= ifobj.contentWindow.document.body.scrollHeight;
            }
        }
    </script>

    //PS: XXX.htm不可跨域

    <iframe src="dd.html" id="frmMain" name="frmMain" width="99%" height="100%" frameborder=0 scrolling=no marginHeight=0 marginWidth=0 onload="Javascript:SetWinHeight(this)" ></iframe>

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



  • 相关阅读:
    在一个很长的字符串中搜索自定义字符串的问题(通过多线程实现)
    老鼠走迷宫
    js控制父子页面传值(iframe和window.open)
    C#后台跳转
    CSS小技巧-图片自动缩放
    js中去除换行( )
    js去除首尾空格
    JQuery隔行变色
    Web开发在线工具
    JQuery标签去重与数组去重
  • 原文地址:https://www.cnblogs.com/xgbzsc/p/2724186.html
Copyright © 2011-2022 走看看