<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"
<title> "tic tac toe"</title>
<script language="JavaScript">
var Next = "X";
var count = "O";
var square= new Array()
for (var i=0; i<9; i++) square[i] = true;
function makeMove(squareindex)
{
if (square [squareindex] == true;
}
(square [squareindex] == true;
count++;
document.getElementById(squareindex).value = ""+next+"";
if Next == "X";
{
Next == "O";
}
else
{
Next == "X";
}
if (count == 9) document.getElementById("toeDisplay").innerHTML="Game Over!";
else document.getElementById("toeDisplay").innerHTML= It is/""+next+""/'s turn";
}
else
{
document.getElementById("toeDisplay").innerHTML = "Fail";
}
}
</script>
</head>
<body>
tic tac toe
<table border=1 id="tictactable"><form name="tic tac toe"></form>
<tr>
<td id="toeDisplay" colspan=4 align=center bgcolor=white> It is "X"'s turn</td>
</tr>
<tr>
<td align=center><INPUT id="0" TYPE="button" value=" "onClick="makeMove(0)"></td>
<td align=center><INPUT id="1" TYPE="button" value=" "onClick="makeMove(1)"></td>
<td align=center><INPUT id="2" TYPE="button" value=" "onClick="makeMove(2)"></td>
</tr>
<tr>
<td align=center><INPUT id="3" TYPE="button" value=" "onClick="makeMove(3)"></td>
<td align=center><INPUT id="4" TYPE="button" value=" "onClick="makeMove(4)"></td>
<td align=center><INPUT id="5" TYPE="button" value=" "onClick="makeMove(5)"></td>
</tr>
<tr>
<td align=center><INPUT id="6" TYPE="button" value=" "onClick="makeMove(6)"></td>
<td align=center><INPUT id="7" TYPE="button" value=" "onClick="makeMove(7)"></td>
<td align=center><INPUT id="8" TYPE="button" value=" "onClick="makeMove(8)"></td>
</tr>
</table>
</body>
</html>
你好呀!我得到了 JavaScript tic-tac-toe 程序的这段代码,但无法让它工作。我究竟做错了什么?我进行了拼写检查,没有找到任何东西,但它仍然无法正常工作。它应该像正常的井字游戏一样运作。您的“X”和计算机将是“O”。当您按下按钮时,它会使计算机移动,而我似乎无法使其正常工作。