window.opener = null;
window.open("", "_self");  
window.close();
我用如下的代码效果是,我点一下button,会弹出一个新的窗口,继续点button才会关闭,这是什么问题啊?请赐教了!
 

解决方案 »

  1.   

    window对象是什么?把这个window的代码发出来看看,就这三句没法帮你测试
      

  2.   

    我用WINFORM写了个代码:
    FormValue window = new FormValue();//FormValue 是我创建的一个窗口
    window.Show();
     window.Close();运行后窗口一闪就自动关闭,没问题
      

  3.   

    window.opener = null;
    window.open("", "_self");  
    return;我点一下button,会弹出一个新的窗口,继续点button才会关闭,这个是因为浏览器防止恶意关闭
      

  4.   

    在模式窗口里面,执行window.close()
      

  5.   

    你明白什么是模式窗口吗?
    window.showModalDialog()才是模式窗口。你的关闭是什么按钮执行的?
      

  6.   

    var winm = window.open();
    winm.close();
      

  7.   


    <script>
    var winm = window.open();
    winm.close();
    </script>
      

  8.   


        window.opener =null;
        window.open('','_self','');
        window.top.close();
      

  9.   

    <html>
    <head>
    <title>
    <base target="_self"></title>
    </head>
    <body>
    </body>
    </html>
      

  10.   

    var winm = window.open();
    winm.close();
      

  11.   

    前台:
    function ADD(id) {
            var leftmar = (window.screen.width - 950) / 2;
            var topmar = (window.screen.height - 650) / 2;
            var count = window.showModalDialog(xxx.aspx?eid='+id, '提示', 'dialogHeight=570px; dialogWidth=1000px; dialogTop=' + topmar + '; dialogLeft=' + leftmar + ';status=no');
            if (count == 1)
                window.location.reload(); //刷新页面    }后台:
    Page.ClientScript.RegisterStartupScript(Page.GetType(), "alertFun", "<script type='text/javascript'>alert('成功!');window.returnValue=1;window.close();</script>");
      

  12.   

    To fyxq14hao:
     按照你的方法父窗体不能刷新,不断提示我要重试,这个怎样解决呢?
      

  13.   

    请大侠们帮忙解决了,现在模式窗口可以关闭了,就是不能刷新父窗口,我的代码是
    <script language=javascript> var arr = window.showModalDialog('" + URL + "','','dialogWidth:" + Win_Width + "px;"
                        + "dialogHeight:" + Win_Hight + "px;status:0');if(arr == 1) {window.location.reload();}</script>模式窗口中是
    <script language=javascript>window.opener = null;window.returnValue=1;window.close();</script>
    总是提示我要重试,这要怎么解决呢?