layer的iframe层的传参和回参

从父窗口传参给iframe,参考://https://yq.aliyun.com/ziliao/133150

从iframe回参给父窗口,参考:https://www.cnblogs.com/jiqing9006/p/5135697.html

父窗口隐藏ID

<input type='text' id="handle_status" value="" hidden="hidden">

父窗口核心两个方法是success,end

                layer.open({
                    type:2,
                    content: '/role/edit?id='+id,
                    area:['500px', '500px'],
                    success:function(layero, index){
                        //向iframe页的id=age的元素传值 
                        var body = layer.getChildFrame('body', index);
                        body.contents().find("#age").val(111);
                    },
                    end:function(){
              //父窗口有一个隐藏id=handle_status的元素,从这里取iframe返回值 var hstatus = $('#handle_status').val(); alert(hstatus); } });

iframe窗口写值给父窗口id=handle_status

            var index = parent.layer.getFrameIndex(window.name); //取得iframe窗口index值
                parent.$("#handle_status").val(555); //向父窗口写值
                parent.layer.close(index); //根据index值,关闭iframe窗口
原文地址:https://www.cnblogs.com/huhu1020387597/p/9718433.html