layui 通用iframe弹窗解决了下拉菜单被遮挡
/**
* 弹窗通用
* @param type 类型 0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
* @param title 窗口标题
* @param id 为指向一个触发按钮
* @param PathImg 上传接口
* @param w 宽
* @param h 高
* @param use 来路用途务
*/
function winner_open(type,title,id,PathImg,w,h){
layer.open({
type: type,
title: title,
anim: '1',
maxmin: false,
resize: false,
shade: [0.3, '#393D49'],
//maxmin: true, //开启最大化最小化按钮
area: [w,h],
content: [PathImg, 'no'],
btn: ['确认', '关闭'],
yes: function(index, layero){
var iframeWin = window[layero.find('iframe')[0]['name']];
var form = iframeWin.document.getElementById('dosubmit');
form.click();
}, function(index){
layer.close(index);
return false;// 取消
},
success: function(layero, index) {
var obj = $(layero).find('.layui-layer-content');
obj.css('position', 'relative');
obj.css('z-index', 198912345);
obj.css('height', $(window).height() + 'px');
obj.css('overflow', 'hidden');
layer.iframeAuto(index);
var btn = obj.parents('.layui-layer').find('.layui-layer-btn');
btn.css('bottom', 0);
btn.css('right', 0);
btn.css('position', 'absolute');
btn.css('z-index', '198912346');
layero.find('iframe').css('height', $(window).height() + 'px');
}
});
}
主要定义了CSS如下代码
var obj = $(layero).find('.layui-layer-content');
obj.css('position', 'relative');
obj.css('z-index', 198912345);
obj.css('height', $(window).height() + 'px');
obj.css('overflow', 'hidden');
layer.iframeAuto(index);
var btn = obj.parents('.layui-layer').find('.layui-layer-btn');
btn.css('bottom', 0);
btn.css('right', 0);
btn.css('position', 'absolute');
btn.css('z-index', '198912346');
layero.find('iframe').css('height', $(window).height() + 'px');