zoukankan      html  css  js  c++  java
  • 解决iframe高度问题

    1

      function calcPageHeight(doc) {
        var cHeight = Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)
        var sHeight = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight)
        var height  = Math.max(cHeight, sHeight)
        var height1 = height+430
        return height1
    }
    //根据ID获取iframe对象
    var ifr = document.getElementById('mainFrame')
    ifr.onload = function() {
        //解决打开高度太高的页面后再打开高度较小页面滚动条不收缩,第一步置为绝对不能少,否则后面会一直保持一个高度
        ifr.style.height='0px';
        var iDoc = ifr.contentDocument || ifr.document
        var height = calcPageHeight(iDoc)
        ifr.style.height = height + 'px'
    } 

    2

    //函数形式
    function
    iframeH(){ //设置iframe高度 parent.document.getElementById("mainFrame").height=0+"px"; parent.document.getElementById("mainFrame").style.height = ""; var h = $(document.body).height() + 120; parent.document.getElementById("mainFrame").height = h; }

    //选择元素形式

    $(window.parent.document).find("#mainFrame").load(function () {
          if($(document).height()!=null&&$(document).height()!='0'){
              parent.document.getElementById("mainFrame").height=0+"px";
             parent.document.getElementById("mainFrame").style.height = "";
          parent.document.getElementById("mainFrame").height = $(document).height();
    }
    });

     
  • 相关阅读:
    sql server 跨库操作
    FPGA使用技巧
    MATLAB学习(3)
    FPGA统计摄像头输出-基于MD9T112
    zedboard VmodCAM 图像采集 HDMI输出显示
    VmodCAM图像采集 VGA显示
    EDK中如何使用ISE中生成的IP
    如何将HDL文件实例化到XPS中
    ubuntu下安装 Source insight
    VmodCAM 初始化
  • 原文地址:https://www.cnblogs.com/zhoujingguoguo/p/9643034.html
Copyright © 2011-2022 走看看