其他分享
首页 > 其他分享> > 4.6 父子窗口传参

4.6 父子窗口传参

作者:互联网

1.父窗口获取子窗口的参数

--html <form name="form1" action="..." style="display: none;"> <input name="feild1" /> <input name="feild2" /> </form> <button onclick='export_new()'>分页导出</button>   --js function export_new(){ var ttt=window.open("tanchu.html",'_blank','width=300px,height=150px,toolbar=no,menubar=no,top=200px,left=450px'); //var res=ttt.returnValue; //var start=ttt.document.getElementById("start").value; //var end=ttt.document.getElementById("end").value;   /*var start=form1.feild1.value; var end=form1.feild2.value; alert("uuuu"+start+"---"+end);*/ }     2.子页面tanchu.html中 填好参数后点击确定 function confirm1(){ var xuanze=$('input[name="xuanze"]:checked').val();   var start=document.getElementById("start").value; var end=document.getElementById("end").value; //window.returnValue= start+","+end; window.opener.getDaoChu( xuanze, start+","+end); window.close(); }   3.在父页面中定义方法执行相应操作 function getDaoChu(xuanze,ress){ if(xuanze=="1"){ toExcel(event); //上面定义的变量方法这么用 //return; } var re=new Array(); re=ress.split(","); var start=re[0]; var end=re[1]; //如何给表单赋值 form1.feild1.value=re[0]; form1.feild2.value=re[1]; //form1为本页面表单 field1、2为表单元素   var data={ "orgNo":$("#orgNo").val(), "level":$("#level").val(), "statYm":$("#statYm").val(), "sort":sort, "tgParam":$("#tgParam").val(), "tgParam1":$("#tgParam1").val(), "pageIndex":start+","+end } var mdata=JSON.stringify(data); $.ajax({ type: "post", url: comurl+"/area/areaLean/synthesize", data: mdata, timeout: 60000, async: true, contentType: "application/json; charset=utf-8", beforeSend: function(XMLHttpRequest) { XMLHttpRequest.setRequestHeader("token", "6666"); }, success:function(json){ //console.log("synthesize_export---"+JSON.stringify(json)); if(json.data.returnCode=='1000'){   var array=json.data.list; var shead=$("thead").html(); //方法1 //tableToExcel(shead,array);   //方法2 拼接html combines(shead,array);   }else if(json.data.returnCode=='1001'){ alert(json.data.returnMsg); }else{ alert(json.data.returnMsg); }   }, error:function(e){ console.log("select1--error"+e.getMessage); }   });   }

标签:传参,4.6,end,value,start,json,var,窗口,data
来源: https://www.cnblogs.com/zl-programmer/p/15284668.html