Javascript 通过单击确认框中的取消关闭我的父窗口。我想取消它应该在同一页上

Javascript 通过单击确认框中的取消关闭我的父窗口。我想取消它应该在同一页上,javascript,Javascript,单击确认框中的取消关闭我的父窗口。我想取消它应该留在同一页。我已经为此编写了以下代码 function closeEditorWarning(){ var r=confirm("This will close all the opened windows of application.Do you want to continue."); if (r==true) { for (var i=0;i<childWindow.length;i++

单击确认框中的取消关闭我的父窗口。我想取消它应该留在同一页。我已经为此编写了以下代码

function closeEditorWarning(){
    var r=confirm("This will close all the opened windows of application.Do you want to continue.");
    if (r==true)
    {   
         for (var i=0;i<childWindow.length;i++) {
                if (childWindow[i] && !childWindow[i].closed)
                    childWindow[i].close();
              }
         self.close();
         }
   else
      {
      }
}
window.onbeforeunload = closeEditorWarning;
函数closeEditorWarning(){
var r=confirm(“这将关闭应用程序所有打开的窗口。是否继续”);
如果(r==true)
{   

对于(var i=0;i您是否尝试删除
self.close();

编辑:试试这个

window.onbeforeunload = function() {
    closeEditorWarning();
    return null;
}

是的,我已经试过了,而且我还在self.close()上设置了提醒但按“取消”时不会调用该功能。Paul,按“确定”或“取消”会将我带到的另一个弹出窗口。您确定要离开此页面吗?我不希望出现第二个弹出窗口。我的代码功能是按“确定”时所有子窗口和父窗口都关闭,这是确定的,但按“取消”时子窗口不会关闭,但已关闭窗户关上了,我不想这样