1. 父页面返回值接收
<script type="text/javascript">
var timer;// 计时器
function showDialog() {
var strParam = "页面跳转路径";
var feature = "dialogWidth=600px;dialogHeight=400px;center=yes;status=no;resizable=no;menubar=no;scroll=no";
if(navigator.userAgent.indexOf("MSIE")>0 || navigator.userAgent.indexOf("Firefox")>0){
var retValue = window.showModalDialog(strParam,"",feature);
if(retValue != undefined) {
setReturnValue(retValue);
}
}else{
//非IE 非Firefox
feature = "width=600px;height=400px;status=no;resizable=no;menubar=no;scrollbars=no";
winOpen = window.open(strParam,"newWindowSel",feature);
timer= window.setInterval(
ifWindowClosed()
,500);
}
}
function ifWindowClosed() {
var retValue = window.returnValue;
if(retValue != undefined) {
setReturnValue(retValue,);
}
}
// 将弹出框页面的值设定到本页面
function setReturnValue(returnValue) {
$("#id").val(returnValue[0]["id"]);
$("#name").val(returnValue[0]["name"])
// 关闭弹出框后,停止计时器
window.clearInterval(timer);
}
<html>
<body>
<input id="id" type="text" value=""/>
<input id="name" type="text" value=""/>
</body>
</html>
</script>
2. 弹出框页面(子页面)返回值赋值
(1)
var returnValueArr = new Array();
var dataValue = new Array();
dataValue["id"] = 值;
dataValue["name"]=值;
returnValueArr.push(dataValue);
//window.open的返回值
if(window.opener){
window.opener.returnValue=returnValueArr;
}
// showModalDialog的返回值设定
window.opener.returnValue=returnValueArr;