![](/img/trans.png)
[英]Attach a modal window to a button and wait for the modal window to close before continue with the button action
[英]Wait for a newly opened window to close before continue
我正在使用一個帶有window.open
的循環,我正在尋找一種方法來等待前一個窗口關閉,然后再啟動下一個窗口。
for(...){
window.open('index.html', '_blank', 'nodeIntegration=yes');
簡單的 for 循環不起作用。 這可以通過 setInterval 來實現。 請參考下面的代碼。
var MyWin = null;//window obejct will assign in future
var i = 0;//Strating index of loop
var len = 5;//length of loop
var myInterval = setInterval(function () {
if ((!MyWin || MyWin.closed) && i < len) {
MyWin = window.open("http://www.google.com/");
i++;
}
else if (i >= len) {
clearInterval(myInterval);//dont forget to clear interval
}
}, 100);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.