我在父页面中用了一个javascript函数:
<script>
function getCustomer() {
    var h=(screen.height-580)/2;
    var w=(screen.width-480)/2;
  window.open ("customerlist.jsp", "newwindow", "height=580, width=480, top="+h+",left="+w+",toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");}
</script>
意在子窗口中返回值,给父窗口。
子窗口的返回函数如下:
function cc()
  {
  var aa = document.getElementsByName("customer");
  var customer;
  for (var i=0; i<aa.length; i++)
   {
        if(aa[i].checked){
        opener.document.getElementById('customername').value=aa[i].value;
        window.close();
        }
   }
        alert("must choose a customer");
}
运行过程中值可返回,但是子窗口不能按预想的关闭,并且还弹出alert,实在不解,请大虾开释。
alert点掉后,子窗口变成空白,父窗口正确结果。

解决方案 »

  1.   

    改代码为:
    ......
            if(aa[i].checked){
               opener.document.getElementById('customername').value=aa[i].value;
               window.close();
               return;
            }......
      

  2.   

    谢谢你的回复,alert不再出现了,可是子窗口还是不能自动关掉,window.close()好像不起作用。
      

  3.   

    那问题应该不是出在window.close()上!你看下调用cc后状态栏有无javascript脚本错误的提示!
    如果有检查一下你window.close前面的代码!
    另外,你去掉浏览器"选项"中"高级"中的"禁止脚本调试"相关项前的勾选,然后关闭重启浏览器再测试,此时若有脚本错误会弹出错误框,你若安装visual stadio 6还可以使用其中的工具进行音频调试!
      

  4.   

    若有脚本错误会弹出错误框,你若安装visual stadio 6还可以使用其中的工具进行音频调试!错了两个字:
    若有脚本错误会弹出错误框,你若安装visual stadio 6还可以使用其中的工具进行单步调试!
      

  5.   

    应该是你window.close()前面的脚本有问题
      

  6.   

    若有脚本错误会弹出错误框,你若安装visual stadio 6还可以使用其中的工具进行单步调试!晕,vs也写错了!反正知道是啥就行了!