前言:我是用的layer彈出框整的layer父子頁面
【父-->子】 【子-->父】
//子彈窗給父頁面元素賦值
parent.$("#parentInput").val("這是從彈窗傳遞過來的數據");
//子彈窗調用父頁面方法
window.parent.childInvokerMethod();
//子彈窗獲取父頁面元素的值
window.parent.$("#shiva").val()
//彈框代碼
var idx = layer.open({
type: 2,
title: '子頁面',
maxmin: true,
area: ['800px', '500px'],
content: './child1.html'
});
//父頁面調用子彈窗的 js方法
var contentWindow = $("#layui-layer-iframe" + idx)[0].contentWindow;
contentWindow.yourMethod();
//父頁面給子彈窗頁面賦值
$("#layui-layer-iframe" + idx).contents().find("input").val("11111111");
【子-->兄弟】 【兄弟-->子】
A頁面彈出B A 頁面 彈出C
A頁面彈出B ,再從B 頁面彈出C B C平級 調用 parent.layer.open({});
//調用兄弟頁面方法
var contentWindow = window.parent.$("#layui-layer-iframe" + idx)[0].contentWindow;
contentWindow.brotherInvokeMethod();
//給兄弟頁面元素賦值
window.parent.$("#layui-layer-iframe" + idx).contents().find("input").val("11111111");
這裏的 idx 可以通過url 帶參數的方式 傳遞到後臺,然後再傳遞回來 或者 使用隱藏表單域進行解決。