iframe 自适应

<iframe frameborder="0"  width="100%" height="100%" id="gzglym" scroll="no" src=""></iframe>

父页面代码

     // iframe自适应高度
      function changeFrameHeight(){
            var ifm= document.getElementById("gzglym");
            ifm.height=document.documentElement.clientHeight-56;
        }
    window.onresize=function(){ changeFrameHeight();}
    changeFrameHeight();

子页面代码

//列表高度设置
function lbHeight(total,iframeId){
    // 每行高度
    var heig = 35;
    // 初始高度
    var befHeig = 83;
    // 数据数量
    var cont = parseInt(total);
    if(cont >= 10){
        befHeig += 10 * heig - 7;
    }else{
        befHeig += cont * heig - 7;
    }
    $("#" + iframeId).animate({"height": befHeig+"px"}, "normal");
}

 

posted @ 2022-06-20 16:18  前端搬运工bug  阅读(44)  评论(0编辑  收藏  举报