我的[网站]:http://www.zombrom.com/experiments/popular.html有一个自动重新加载,每次重新加载时它会重新打开页面我想知道如何立即关闭所有这些网站这里是我赢得的当前代码打开更多的网站:
setInterval(function() {
location.reload();
window.open("http://www.zombrom.com/experiments/popular.html");
}, 1000);
<center><b>Ready!</b>
</center>
答案 0 :(得分:-2)
您可以使用window.close()
var openWindows = [], newWindow;
setInterval(function() {
/* Will not work with location.realod() */
//location.reload();
//push reference to the opened windows into an array
newWindow = window.open("http://www.zombrom.com/experiments/popular.html");
openWindows.push(newWindow);
}, 1000);
/* call this function when you want to close all the windows that you have opened*/
function closeAllOpenWindows(){
openWindows.forEach(function(openWindow){
openWindow.close();
}
);
}