js弹窗返回值详解(window.open方式)

今天在改公司一个老系统时,碰到了window.open()的这个语法。虽然这个方法有点老,不太用了。所以有点不清楚父级弹框如何获取子级页面返回的值。为了解决这个问题,上网搜了一下。原作者参考网址:http://blog.csdn.net/xmwangtiger/article/details/4234054

这里重点总结一下啊!

语法:window.open("sUrl","sName","sFeature","bReplace"); 

使用:1:  在父级页面 test.aspx 的点击<input type="button" id="btnShow" οnclick="showItem();"  value="显示子窗体"/>按钮触发 ,然后 :

  <script language="javascript" type="text/javascript">
   function showItem() {

         var  win = window.open("test2.aspx",null," height=300,width=450,  Left=300px,Top=20px, menubar=no,titlebar=no,scrollbar=no,toolbar=no, status=no,location=no");

  }

 

  2: 在子级页面test2.aspx的点击<input type="button" id="btnSelect" οnclick="check();"  value="选择"/> 按钮触发,然后:

    <script language="javascript" type="text/javascript">
   function check() {

          window.opener.document.getElementById("txtId").value=id;
          window.opener.document.getElementById("txtName").value=name;

  }

 

  这样,父级页面的document.getElementById("txtId") 和 document.getElementById("txtName") 2个控件就可以得到子级页面的返回值。

 

转载于:https://www.cnblogs.com/shj-com/p/8251301.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值