從父窗口傳參給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窗口
