I have a function that should open an authentication window (IwAuthentication) and after 5 sec close that window and open a new one (IwUrl). I tried lot of code and I am able to complete all tasks but window.Close it doesn't work and my IwAuthentication still open. Any advices? My code below
我有一个应该打开一个身份验证窗口(IwAuthentication)的函数,并在关闭该窗口5秒后打开一个新窗口(IwUrl)。我尝试了很多代码,我能够完成所有任务但是窗口。关闭它不起作用,我的IwAuthentication仍然打开。有什么建议吗?我的代码如下
Thanks!
var IwAuthentication = "http://etc";
var IwUrl = "http://etc");
function openwindowAuthentication() {
var myWindow = window.open(IwAuthentication, "myWindow", "width=500, height=500");
}
window.setTimeout(function () {
window.open(IwsUrl, myWindow, "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
closewindowAuthentication();
}, 5000);
function closewindowAuthentication() {
myWindow = window.close(); // Closes the new window
}
2 个解决方案
#1
0
Try this
var myWindow = window.open(IwAuthentication, "myWindow", "width=500, height=500");
setTimeout(function () {
myWindow.close();
}, 5000);
#2
0
You need to do 2 things
你需要做两件事
- Declare the variable
myWindow
outside of the function - refer to
myWindow.close()
notwindow.close()
在函数外部声明变量myWindow
请参阅myWindow.close()而不是window.close()
var IwAuthentication = "http://etc";
var IwUrl = "http://etc");
var myWindow = null;
function openwindowAuthentication() {
myWindow = window.open(IwAuthentication, "myWindow", "width=500, height=500");}
window.setTimeout(function () {
window.open(IwsUrl, myWindow1, "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
closewindowAuthentication();
}, 5000);
function closewindowAuthentication() {
myWindow.close(); // Closes the new window
}
#1
0
Try this
var myWindow = window.open(IwAuthentication, "myWindow", "width=500, height=500");
setTimeout(function () {
myWindow.close();
}, 5000);
#2
0
You need to do 2 things
你需要做两件事
- Declare the variable
myWindow
outside of the function - refer to
myWindow.close()
notwindow.close()
在函数外部声明变量myWindow
请参阅myWindow.close()而不是window.close()
var IwAuthentication = "http://etc";
var IwUrl = "http://etc");
var myWindow = null;
function openwindowAuthentication() {
myWindow = window.open(IwAuthentication, "myWindow", "width=500, height=500");}
window.setTimeout(function () {
window.open(IwsUrl, myWindow1, "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
closewindowAuthentication();
}, 5000);
function closewindowAuthentication() {
myWindow.close(); // Closes the new window
}