我在A页面上有一个按钮和一个文本框,点击按钮后用showModalDialog打开一个弹出页,弹出页里有很多checkbox,我的目的是在弹出页里把勾选的项的文本传回到A页面里的文本框里(在弹出页里选好项后点击一个按钮传)...  

解决方案 »

  1.   

    弹出的页面:   
      window.returnValue   =   xxx;   
    接收页面:   
      document.all.txt.value   =   showModalDialog('','','');
      

  2.   

    楼上的正解.也可以通过dialogArguments传递一个对象过去,
    然后在新窗口设置该对象的属性当作返回值.
    醉翁之意不在答问题,在于发广告也------------------------------------------------我们要新招一个JavaScript的开发人员哦.有人有兴趣来吗??
    http://www.cnblogs.com/Lostinet/archive/2008/01/31/1059527.html
      

  3.   

    index.html
    <script>
    function hehe()
    {
        var result = window.showModalDialog("index2.html","","dialogLeft=100;dialogTop=150;dialogWidth=200px;dialogHeight=100px;status=no");
        var haha = document.getElementById("haha");
        haha.value="";
        for(var i=0; i<result.length; i++)
        {
          haha.value += result[i];
        }
    }
    </script>
    <input type="text" id="haha" />
    <input type="button" value="Test" onclick="hehe();" />index2.html
    <script>
    function hehe()
    {
      var index=0;
      var array = new Array();
      var checks = document.getElementsByName("hehe");
      for(var i=0; i<checks.length; i++)
      {
        if(checks[i].checked==true)
        {
          array[index++]=checks[i].value;
        }
      }
      window.returnValue = array;
      window.close();
    }
    </script>
    <input type="checkbox" name="hehe" value="A" />A
    <input type="checkbox" name="hehe" value="B" />B
    <input type="checkbox" name="hehe" value="C" />C
    <input type="checkbox" name="hehe" value="D" />D
    <input type="checkbox" name="hehe" value="E" />E<br>
    <input type="button" value="Test" onclick="hehe()" />
      

  4.   

    index.html
    最后一行在添加一行
    window.onunload=hehe;
      

  5.   

    可以把A页面的整个window对象传过去。这样想调用什么就OK了
      

  6.   

    把Window都穿过去有没有效率问题啊