layui 彈窗的iframe 父子界面相互傳值

1.父界面向子界面傳值

  [1].父界面打開子界面:

function show_layer(){
layer.open({
        type: 2,
        area: [w+'px', h +'px'],
        fix: false, //不固定
        maxmin: true,
        shadeClose: true,
        shade:0.4,
        title: title,
        content: url,  //url 爲子佈局的url路徑
        success:function (layero,index) {
                var iframe = window['layui-layer-iframe' + index];
                iframe.child('我是父佈局傳到子佈局的值')
        }
    });
}

  [2].子界面接收父界面的值

function child(obj){
    console.log(obj);//獲取父界面的傳值
}

 

2.子界面向父界面傳值

  [1].子界面向父界面傳值

parent.GetValue('我是子界面的數值'); //GetValue是父界面的Js 方法
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);

  [2].父界面接收子界面的值

function GetValue(obj){
    console.log(obj);
}
相關文章
相關標籤/搜索