layer.open iframe自动高度


layer.open({
type: 2,
title:"Iframe页面标题",
    shadeClose: true,
area: ['600px'],
success: function(layero, index) {
//找到当前弹出层的iframe元素
var iframe = $(layero).find('iframe');
var iframeHeight=iframe[0].contentDocument.body.scrollHeight;
if((window.innerHeight)>(iframeHeight+40)) {//40为
title标题高度
            //设定iframe的高度为当前iframe内body的高度
iframe.css('height', iframeHeight);
}
},
content: '
aaa.html',
})
posted @ 2021-12-03 16:25  为乐而来  阅读(568)  评论(0编辑  收藏  举报