帮你写了一个 你看看:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
<HTML><HEAD><TITLE></TITLE>  
<META http-equiv=Content-Type content="text/html; charset=gb2312">    
  </head>
<body onunload="confirm('really close the window??');">
<SCRIPT language=javascript>  
function getData(){
var win=window.open("",null,"height=600,width=600,status=yes,toolbar=no,menubar=yes,location=no");
var str='<select multiple size="7"><option value="1">1</option><option value="2">2</option><option';
str+='value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option>';
str+='</select><input type="button" onClick="closeWin()">';
str+='<script language="javascript">function closeWin(){ var sel=document.getElementsByTagName("select")[0];\n var ary=[];\n';
str+='for(var i=0;i<sel.options.length;i++)\n{ if(sel.options[i].selected) \nary.push(sel.options[i].value);}\n';
str+='opener.document.getElementById("userId").value=ary.toString();\n window.close();}</'+'script>';
win.document.write(str);
win.document.close();}
</script> <input type='button' value='得到数据' onclick='getData();'>
<input type='text' id='userId'>
</BODY>
</html>

解决方案 »

  1.   

    不好意思把 <body onunload="confirm('really close the window??');">改成   <body >  ^-^
      

  2.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
    <HTML><HEAD><TITLE></TITLE>  
    <META http-equiv=Content-Type content="text/html; charset=gb2312">    
    </head>
    <!--<body onunload="confirm('really close the window??');">-->
    <body>
    <SCRIPT language=javascript>  
    function getData(){
        var win=window.open("",null,"height=600,width=600,status=yes,toolbar=no,menubar=yes,location=no");
        var str='<select multiple size="7"><option value="1">1</option><option value="2">2</option><option';
        str+='value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option>';
        str+='</select><input type="button" onClick="closeWin()">';
        str+='<script language="javascript">function closeWin(){ var sel=document.getElementsByTagName("select")[0];\n var ary=[];\n';
        str+='for(var i=0;i<sel.options.length;i++)\n{ if(sel.options[i].selected) \nary.push(sel.options[i].value);}\n';
        str+='opener.document.getElementById("userId").value=ary.join(";");\n window.close();}</'+'script>';
        win.document.write(str);
        win.document.close();}
    </script> 
    <input type='button' value='得到数据' onclick='getData();'>
    <input type='text' id='userId'>
    </BODY>
    </html>
      

  3.   


    bb.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
     <script>
    function openWin(){ var mydata = window.showModalDialog("aa.html",null,"dialogWidth:500px;dialogHeight:600px;center:yes"); if(mydata){
    document.getElementById('txt').value = mydata;
    }
    }
     </script>
     </HEAD> <BODY>
    <input type="text" id="txt" value="" >
      <input type="button" value="   打开窗体  " onclick="openWin()">
     </BODY>
    </HTML>
    aa.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <script>  function ok(){
    var arrRevalue = new Array();
    var oSel = document.getElementById('sel');
    var num =oSel.options.length;
    for(var i=0;i<num;i++){
    arrRevalue.push(oSel.options[i].value);
    }
    window.returnValue = arrRevalue.join(';').toString();
    window.close();
      }  </script> </HEAD> <BODY>
      <select size="5" id="sel" multiple onclick="reValue(this)">
      <option value="111">111</option>
      <option value="333">333</option>
      </select>  <input type="button" value="ok" onclick="ok()">
     </BODY>
    </HTML>