window.onload=initAll;
var usedNum = new Array(76);
function initAll(){
//-----------检查浏览器是否支持js
if (document.getElementById){
document.getElementById("reload").onclick = anotherCard;
newCard();
}
else {
alert("Sorry,your broeser doesn't support this script")
}
}
function newCard(){
for (var i=0;i<24;i++){
setSquare(i);
}
}
function setSquare(thisSquare){
var currSquare = "square" + thisSquare;
var colPlace = new Array(0,0,0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4);
var colBasis = colPlace[thisSquare] * 15;
var newNum;
do{
newNum = colBasis + getNewNum() + 1;
}
while(usedNum[newNum]);
usedNum[newNum]=true;
document.getElementById(currSquare).innerHTML = newNum;
}
function getNewNum(){
return Math.floor(Math.random() * 15);
}
function anotherCard(){
for (var i=1;1<usedNum.length;i++){
usedNum[i]=false;
}
newCard();
}
click之后就崩了