window.open()在IE6和IE7中不工作

window.open() is not working in IE6 and IE7

本文关键字:IE7 工作 IE6 open window      更新时间:2023-09-26

我有一个dotnet应用程序,我必须关闭当前窗口,然后在运行时再次打开新窗口。我使用了Javascript。代码如下:

function OpenNewWindow() {
    if (ConfirmStartTest()) {
        closeWindow();
window.open("OnlineTestFrame.aspx", "_Parent", "model=yes,dailog=no,top=0,height=screen.height,width=screen.width,status=no,toolbar=no,menubar=no,location=no,zoominherit =0,resizable =no,scrollbars=yes,dependent=no,directories=no,taskbar=no,fullscreen=yes");
        self.focus();
    }
}
//taking the confirmation for starting test
function ConfirmStartTest() {
    var result = confirm("Do you want to start the test now?");
    return result;
}
//function to close the current window
function closeWindow() {
     //var browserName = navigator.appName;
     //var browserVer = parseInt(navigator.appVersion);
     var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;  
     if (ie7) 
           {     
           //This method is required to close a window without any prompt for IE7
           window.open('','_parent','');
           window.close();
           }
     else 
           {
           //This method is required to close a window without any prompt for IE6
           this.focus();
           self.opener = this;
           self.close();
           }
}

现在,当我在IE7和IE6中运行这个应用程序时,它没有运行。但是,在IE8中它运行得很好。

此代码在以前的所有IE6和IE7中都可以正常工作。突然就产生了误差。它不能打开新窗口并在b/w中突然停止。

如果有人对此有任何意见,请告诉我。

这是由于self.opener的分配。

12/04 Microsoft开始通过Windows Update发布安全公告MS11-018,该公告关闭了与内存相关的几个漏洞-其中一个影响opener属性,该属性不再可以分配给

没有什么比关闭一个窗口并期望它之后的任何东西想要运行更重要的了。

代码流程

  1. 函数调用
  2. <
  3. 关闭窗口/gh>
  4. 打开窗口<—如果父窗口关闭,我如何运行?
  5. 关注窗口

(咆哮)你在这里试图做的是强迫用户使用你自己的弹出窗口,所以它没有chrome,这是非常糟糕的用户体验。您正在删除用户历史记录。别管我的浏览器!有一个原因,你必须做一些黑客的东西来关闭一个窗口,浏览器不允许你这样做。[/咆哮]