弹窗添加数据后实现父级页面同步添加

弹窗:

function openUrl() {
var iWidth = 800;
var iHeight = 600;
return window.open('<%= Application["rootURL"] %>AP_ImageIndexing/Indexing/AddPo.aspx', 'AddPO', 'width=' + iWidth + ',height=' + iHeight + ', top=' + (screen.height - iHeight) / 2 + ', left=' + (screen.width - iWidth) / 2 + ',resizable=1,scrollbars=1');
}

数据回调:

//获取并设置父级元素,这种是asp.net获取ID的方式
$("[id$=add_polist_value]", window.opener.parent.document).val(value2);

原理:在父级页面设置一个隐藏标签,子页面获取该ID并赋值,这样就完成了子页面向父级页面通信。

父页面给子页面传值一般通过URL地址附带!

子页面完成操作后父页面刷新:

window.opener.parent.document.forms[0].submit();

原文地址:https://www.cnblogs.com/it-xcn/p/6061718.html