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 @   前端搬运工bug  阅读(45)  评论(0编辑  收藏  举报
        相关博文:
        阅读排行:
        · 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
        · 使用C#创建一个MCP客户端
        · ollama系列1:轻松3步本地部署deepseek,普通电脑可用
        · 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
        · 按钮权限的设计及实现
        点击右上角即可分享
        微信分享提示