本文介绍了layui弹窗父子窗口之间传参数的方法,分享给大家,具体如下:
代码为打开窗口添加按钮
/* btn: ['确定','取消'],btnAlign: 'c',yes: function(index,layero){
/* //layer.closeAll();//关闭所有弹出层
//var parentWin = layero.find('iframe')[0];
var parentWin = layer.getChildFrame('body',index);
alert(parentWin);
parentWin.contentWindow.doOk();
//layer.close(index);//这块是点击确定关闭这个弹出层
},*/
area: ['750px','450px'],content: url,success: function(layero,index){
var body = layer.getChildFrame('body',index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
var ids = dialogArgumentsA[0].split(",");
var names = dialogArgumentsA[1].split(",");
for (var i = 0; i < ids.length; i++ ) {
if ('' != ids[i]) {
var option = $("
$("#"+selectName+" option").each(function(){
//遍历所有option
var value = $(this).val(); //<a href="https://www.jb51.cc/tag/huoqu/" target="_blank" class="keywords">获取</a>option值
var text = $(this).text();
if(text!=''){
var o = new Element(value,text,0);
ret.push(o);
}
});
return ret;
}
//点击确定向子页面传参并关闭窗口
function doOk(){
var ret = newBuildReturnValue("select");
parent.setChooseValues(ret);
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
}
//点击取消关闭窗口
function doCancel(){
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
}