• Ifram框架适应高度 javascript实现


    <script type="text/javascript">
            //框架自应用高度
            function dyniframesize(down) {
                var pTar = null;
                if (document.getElementById) {
                    pTar = document.getElementById(down);
                }
                else {
                    eval('pTar = ' + down + ';');
                }
                if (pTar && !window.opera) {
                    //begin resizing iframe
                    pTar.style.display = "block"
                    if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
                        //ns6 syntax
                        pTar.height = pTar.contentDocument.body.offsetHeight + 20;
                        pTar.width = pTar.contentDocument.body.scrollWidth + 20;
                    }
                    else if (pTar.Document && pTar.Document.body.scrollHeight) {
                        //ie5+ syntax
                        pTar.height = pTar.Document.body.scrollHeight;
                        pTar.width = pTar.Document.body.scrollWidth;
                    }
                }
            }        
        </script>

    在Ifram处设置:

     <iframe style="vertical-align: top; padding-left: 0px; height: 447px; 720px;
                                        background-color: #EAEEED" onload="javascript:dyniframesize('WorkSpace');" id="WorkSpace"
                                        marginwidth="0" scrolling="no" frameborder="0" name="ifram" src="CompanyManage.aspx">
    </iframe>

    上面这种方法我是在http://bbs.51aspx.com/showtopic-2263.html看来的,但是当你对这个ifram框进行设置了height时,那么当你的内容超过height时就不能进行拉申了;

    以下这种方法他不受你所设置的height的限制:

     <script type="text/javascript">

            if (window != top) top.location = window.location;
            // 调整 Table DesktopFrame 的大小,以使 IFrame WorkSpace 不出现滚动条
            function WorkSpaceLoad() {
                var h = WorkSpace.document.body.scrollHeight;
                if (h > 450)
                    parent.DesktopFrame.height = h;
                parent.document.all.WorkSpace.style.height = h;

               
            }

    </script>

    在有框架的表格上设置:

    <table width="100%" id="DesktopFrame">

     <tr>

    <td>

    <iframe style="vertical-align: top; padding-left: 0px; 725px;
                                        background-color: #EAEEED" id="WorkSpace"  onload="javascript:WorkSpaceLoad();"
                                        marginwidth="0" scrolling="no" frameborder="0" name="ifram" src="CompanyManage.aspx">
      </iframe>

    </td>

    </tr>

    </table>

    但是这两种方法都受到了首次宽度的限制,就是说当你在同一个页面时,有不同的操作,第一个操作显示的内容少,第二个操作显示的内容多;如果说你是先操作第一个,那么当你操作第二个时页面的框架是不会自动拉申的;此问题已经困了很久了,如有高手知道怎么处理请分享一下,非常的感谢,,,,

  • 相关阅读:
    .net 设置默认首页
    MySQL如何对数据库状态值指定排序
    golang将mm-dd-yy的字符串转时间格式
    Nginx文件解析
    Git使用笔记
    批量导入实现逻辑
    golang字符串截取
    golang格式化代码
    golang获取某一年某一月份的开始日期和结束日期
    nslookup install
  • 原文地址:https://www.cnblogs.com/KimhillZhang/p/1730369.html
Copyright © 2020-2023  润新知