2016-05-25 175 views
0

我有一個應該打開認證窗口(IwAuthentication)的功能,5秒後關閉該窗口並打開一個新窗口(IwUrl)。我嘗試了很多代碼,並且能夠完成除窗口以外的所有任務。關閉它不起作用,並且我的IwAuthentication仍然打開。任何建議?我的代碼如下打開一個新窗口並在5秒後關閉窗口

謝謝!

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 
} 

回答

0

試試這個

var myWindow = window.open(IwAuthentication, "myWindow", "width=500, height=500"); 

setTimeout(function() { 
    myWindow.close(); 
}, 5000); 
0

你需要做兩件事情

  1. 聲明變量myWindow外的函數的
  2. 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 
} 
相關問題