实现window.open方式向父窗口返回值
如何实现在不使用window.showModalDialog 的情况下用 window.open方式 向父窗口返回值。
例如:
页面A.htm 用 window.open方式弹出页面 B.htm 。
在页面B.htm上选择一个值,确定关闭窗口后将选择的这个值返回到父窗口A.htm。
A.htm得到返回的值后,给本页面上的文本框赋值。
1.在A.htm里建一个函数:
function sele(NO){ //NO为返回值
alert(NO);//可以直接赋值给表单
var re= new Array();//如果需返回多个变量,则采用数组把各个变量分开
re=NO.split(",");
form1.feild1.value=re[0];
form1.feild2.value=re[1];//form1为本面表单名,feild1、2为表单元素
}
<form name="form1" action="....">
<input name="feild1">
<input name="feild1">
</form>
2.在B,htm 加以下代码
function re(NOre){
window.opener.sele(NOre);
window.close();"
}
<form name="form1" action="....">
<input type="button" value="返回值" onclick="re("把需返回的变量")">
</form>