两个页面,1.htm
<input name="haha" type="hidden">
<script language=javascript>
window.showModalDialog("2.htm",window)
alert(document.getElementById("haha").value)
</script>2.htm
<input name="aa" type="radio" value="1">asdasd
<input name="aa" type="radio" value="2">asdasd2
<input name="haha" type="button" onclick="show()">
<script language=javascript>
function show()
{
var objs=document.getElementsByName("aa") 
for(var i=0;i<objs.length;i++)
{
if(objs[i].checked)
window.dialogArguments.document.getElementById("haha").value=objs[i].value
window.close()
}
}
</script>

解决方案 »

  1.   

    window.opener.text1.value = radio1.value;
      

  2.   

    如果是模态对话框可像1楼那样处理。
    同时,如果返回的值比较多,可采取返回Object对象的办法。
    如:
    var obj = new Object();
    obj.param1 = "a";
    obj.param2 = "b";
    window.returnValue = obj;
      

  3.   

    parent.window.opener.document.all.text1.value = radio1.value
      

  4.   

    noname1.html
    <body id="www.never-online.net">
    <script type="text/javascript">
    //<![CDATA[
    function FnOpenWindow(sPageUrl) {
    var w = window.open(sPageUrl);
    }
    //]]>
    </script>
    <button onclick="FnOpenWindow('noname2.html')">compare</button>
    <table border="1" cellpadding="0" cellspacing="0" width="100%" id="tbl">
    </table>
    </body>
    noname2.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title> - http://www.never-online.net </title>
        <meta http-equiv="ImageToolbar" content="no" />
        <meta name="author" content="never-online, BlueDestiny"/>
        <script type="text/javascript">
        //<![CDATA[
          var prefixName = "neverOnline";
          var openerElementId = 'tbl';
          var checkBoxName = "cb";      function FnGetRow(o) {
            while (o.tagName!="TR") {
              o = o.parentNode;
            }; return o;
          }
          function FnBar(o) {
            var oTr = FnGetRow(o);
            var $ = window.opener.document.getElementById;
            var oTbl = $(openerElementId);
            try { var e = $(prefixName+o.value); } catch(ex) {};
            if (o.checked) {
              if (e) return; else {
                var tr = oTbl.insertRow();
                tr.id = prefixName+o.value;
                for (var i=0; i<oTr.cells.length; i++) {
                  var td = tr.insertCell(i);
                  td.innerHTML = oTr.cells[i].innerHTML;
                }
              }
            } else {
              e?e.parentNode.removeChild(e):"";
            }
          }    //]]>
        </script>
      </head>
      <body id="www.never-online.net">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tr>
            <td><input type="checkbox" name="cb" value="1"/></td>
            <td>information</td>
          </tr>
          <tr>
            <td><input type="checkbox" name="cb" value="2"/></td>
            <td>information</td>
          </tr>
          <tr>
            <td><input type="checkbox" name="cb" value="3"/></td>
            <td>information</td>
          </tr>
          <tr>
            <td><input type="checkbox" name="cb" value="4"/></td>
            <td>information</td>
          </tr>
        </table>
        <script type="text/javascript">
        //<![CDATA[
        var FnLoadEvent = function() {
          var a = document.getElementsByName(checkBoxName);
          for (var i=0; i<a.length; i++) {
            a[i].onclick = function() { FnBar(this); }
          }
        }();
        //]]>
        </script>
      </body>
    </html>