关于用JavaScript:window.open传值的问题

index.asp



<html>
<head>
<title>产品销售title>
<meta   http-equiv="Content-Type"   content="text/html; charset=utf-8"/>
HEAD>
<BODY>
<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1">
      <form name="form1" method="post">
        <tr>      
        <td height="30" align="right">购买客户:td>
        <td class="category"><input name="huiyuan" readonly onClick="JavaScript:window.open('1.asp?form=form1&field=huiyuan&field2=id_huiyuan&field3=zu','','directorys=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=1700,height=800,top=176,left=180');" style="width:150px" value="单击选择客户">
          <input type="hidden" name="id_huiyuan"-->
          <input type="text" name="zu" style="width:120px" readonly>
         td>                
      tr>
      <tr>
        <td width="20%" align="right" height="30">选择产品:td>
        <td width="80%" class="category">
          <table cellpadding="0" cellspacing="0" width="100%" border=0>
            
            <tr>
              <td>
                <p><a href="a.asp?id=<%="id_huiyuan"%>">选择产品a>
              <BR> 需求是:点击这个链接href="a.asp?id=<%="id_huiyuan"%>,要从返回的页面里面得到id_huiyuan这个值p>
              <p>如果客户名录页是含税,下面这个下拉框为含税选中,如果是未税,则未税选中p>td>
              tr>        
            
            table>        td>
      tr>
      <tr>
        <td height="30" align="right">是否含税:td>
        <td class="category">
          <select name="hanshui">
             <option value="0">未税option>
            <option value="1">含税option>
            select>
          
          td>
        tr>
      <tr>
        <td height="30"> td>
        <td class="category">
          <input type="submit" value=" 确认销售 " onClick="return check1()" class="button">td>
        tr>
      form>
table>
body>
html>

1.asp

<meta   http-equiv="Content-Type"   content="text/html; charset=utf-8"/>
HEAD>
<BODY>

<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1">

  <tr 
  onMouseOver="this.className='highlight'" 
  onMouseOut="this.className=''" 
  onDblClick="
  window.opener.document.form1.huiyuan.value='第二个公司';
  window.opener.document.form1.id_huiyuan.value='340757';
  window.opener.document.form1.zu.value='负责业务员:李';
  window.close();">
  <td height="25" align="center">第二个公司td>
  <td align="center">含税td>
    <td align="center">余总td>
  tr>
  

  <tr 
  
  onMouseOver="this.className='highlight'" 
  onMouseOut="this.className=''" 
  onDblClick="
  window.opener.document.form1.huiyuan.value='第三个公司';
  window.opener.document.form1.id_huiyuan.value='340754';
  window.opener.document.form1.zu.value='负责业务员:王';
  window.close();">
    <td height="25" align="center">第三个公司td>
    <td align="center">未税td>
    <td align="center">梁总td>
  tr>
  
  

table>
body>
html>

如上代码,当点击购买客户的输入输时,弹出1.asp页面,在该页面双击选择客户,关闭该页面。
双击后,从1.asp返回一些值到index.asp
需求是:index.asp页要不提交,能取得1.asp传回的值,

已提交源码

关闭页面前你不都已经写完了吗?有啥问题吗?
如果不行你试过在父页面定义一个方法,这个方法接收参数去填充值,在子页面调用

可以通过以下两步处理

  1. index.asp 添加监听 message 事件
    window.addEventListener('message', function (data) {
             alert(data.data)
             console.log(data.data);
         })
    
  2. 1.asp 中在双击时调用
    window.parent.opener.postMessage('我回来了', '*');
    window.close()
    

参考链接