var locationArray =new Array;function mineCoordinate(mineNum,rowCoord,colCoord)//创建不同大小的数组{locationArray.length=0;//重置数组for(var num=0; num<mineNum;num++){var x=Math.round(Math.random()*rowCoord);var y=Math.round(Math.random()*colCoord);locationArray.push([x,y]);}alert("创建成功"+locationArray.length);}function mineLocation(){switch (tableNode.rows[0].cells.length){case 6:mineCoordinate(5,5,5);break;case 12:mineCoordinate(20,11,11);break;case 21:mineCoordinate(18,14,20);break;case 33:mineCoordinate(28,15,32);break;default:alert("未知错误");break;}}function mineVisible(mineNum){var row=event.srcElement.parentNode.rowIndex;var col=event.srcElement.cellIndex;for(var temp=0;temp<mineNum;temp++){if(locationArray[temp][0]==row && locationArray[temp][1]==col)//问题出在这里:会提示数组为空或不是对象,哪里错了呢?????{clearInterval(timeInterval);for(var temp1=0;temp1<mineNum;temp1++){var xRow=locationArray[temp1][0];var xCol=locationArray[temp1][1];tableNode.rows[xRow].cells[xCol].innerHTML="<imgsrc='img/123.jpg' height='19' width='16'/>";}return;}}}
1 回答

动漫人物
TA贡献1815条经验 获得超10个赞
locationArray[temp]不是有效的数组,可能locationArray为空,或者temp操出了locationArray的索引。
for ( var temp=0;temp<mineNum;temp++){ console.log(locationArray[temp]); //你可以输出看看,console.log函数不能在IE下使用 |
添加回答
举报
0/150
提交
取消