[英]window.open() is not working in IE6 and IE7
I have a dotnet application in which I have to close the current window and then open the new window again in runtime.我有一个 dotnet 应用程序,我必须在其中关闭当前的 window,然后在运行时再次打开新的 window。 I have used Javascript for it.
我已经使用了 Javascript 。 The code is as follows:
代码如下:
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();
}
}
Now, when I am running this application in IE7 and IE6, it is not running.现在,当我在 IE7 和 IE6 中运行此应用程序时,它没有运行。 But, in IE8 it is running fine.
但是,在 IE8 中它运行良好。
This code was working fine for all IE6 n IE7 previously.此代码以前适用于所有 IE6 n IE7。 All of a sudden it is giving error.Its not able to open the new window and stopping abruptly in b/w.
突然出现错误。它无法打开新的 window 并在黑白中突然停止。
If anyonw has any idea regarding this, please let me know.如果anyonw对此有任何想法,请告诉我。
Nothing like closing a window and expecting anything after it to want to run.没有什么比关闭 window 并期待它之后的任何东西想要运行。
Flow of the code代码流程
[rant] What you are trying to do here by forcing a user to use your own pop up window so it has no chrome is very bad user experience. [咆哮] 你在这里试图通过强迫用户使用你自己的弹出窗口 window 所以它没有 chrome 是非常糟糕的用户体验。 You are deleting a users history.
您正在删除用户历史记录。 Leave my browser alone, There is a reason why you have to do hacky stuff to close a window.
不用管我的浏览器,你必须做一些骇人听闻的事情来关闭 window 是有原因的。 the browsers do not allow you to do it.
浏览器不允许您这样做。 [/rant]
[/咆哮]
This is due to the assignment of self.opener
.这是由于
self.opener
的分配。
12/04 Microsoft started pushing out Security Bulletin MS11-018 via Windows Update which closed of several vulnerabilities related to memory - one of these affected the opener
property which no longer can be assigned to. 12/04 微软开始通过 Windows 更新推出安全公告 MS11-018 ,该更新关闭了与 memory 相关的几个漏洞 - 其中一个影响了无法再分配的
opener
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.