JS 一个页面关闭多个页面

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<input type="button" value="打开另外一个页面" id="id" />
<input type="button" value="关闭全部另外页面" id="gb" />
</body>
</html>
<script type="text/javascript">
//用一个数组包含打开页面
var bb = new Array();
var count=0;
//打开页面赋值
var a = document.getElementById('id');
//点击打开事件
a.onclick = function () {
bb[count]=window.open('http://www.baidu.com','_blank');
count++;
}

//关闭页面
var gb=document.getElementById('gb');
//点击关闭事件
gb.onclick = function () {
for (var i = 0; i < bb.length; i++)
{ bb[i].close();}
}

</script>

原文地址:https://www.cnblogs.com/zhangwei99com/p/6653501.html