zoukankan      html  css  js  c++  java
  • Iframe 高度自适应的问题

    外层div ,div 内包含iframe  ;如何当内部iframe 高度变化时,外层的div 高度跟着自适应呢?

    1:

    <div>
    <IFRAME height="100%" width="100%" frameBorder=0
    id=inspfrmchild name= inspfrmchild scrolling="no"
    onload="javascript:dyniframesize('inspfrmchild');"
    src="${path }/inspect-Inspinfo-inspinfoDetial.do" allowTransparency="true">
    </IFRAME>
    </div>

    2:

    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 + 29;
    pTar.width = pTar.contentDocument.body.scrollWidth;
    }
    else if (pTar.Document && pTar.Document.body.scrollHeight){
    //ie5+ syntax
    pTar.height = pTar.Document.body.scrollHeight;
    pTar.width = pTar.Document.body.scrollWidth;
    }
    }
    }

    3:当内部iframe 动态变化时,可内部调用JS函数,将外部的div 高度重新生成

  • 相关阅读:
    经典测试面试题一
    自定义函数实现字符串数组互转
    php 实现密码错误三次锁定账号10分钟
    HTTP状态码
    Linux知识点
    慢查日志
    curl 采集
    HTTP协议
    docker配置
    mysql数据库索引、存储引擎、事务
  • 原文地址:https://www.cnblogs.com/leonkobe/p/4041095.html
Copyright © 2011-2022 走看看