我有一个dotnet应用程序,其中我必须关闭当前窗口,然后在运行时再次打开新窗口。我已经使用Javascript。代码如下:window.open()不工作在IE6和IE7
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 n IE7都正常工作。突然间,它发出错误信息。它无法打开新窗口并以黑白方式突然停止。
如果anyonw对此有任何想法,请告诉我。
你说它突然停止工作 - 你之前做了什么改变? – 2011-04-28 13:34:27
此外,我没有看到“自我”变量的初始化,你是否错过了,或者它是否在片段之外? – 2011-04-28 13:35:19
@Niklas - https://developer.mozilla.org/en/window.self – epascarello 2011-04-28 13:36:35