用window.open方式 向父窗口返回值

来源:互联网 发布:淘宝韩版男装 编辑:程序博客网 时间:2024/06/03 22:02

用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为表单元素}


调用window.open部分

var height = 300;var width = 500;var url = "UploadPicTest.aspx";var winOption = "height=" + height + ",width=" + width + ",top=50,left=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=0";window.open(url, window, winOption);

<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>

--- end ---
0 0
原创粉丝点击