简单问题!!!

darkdragon1981 2003-12-12 09:45:06
<html>
<head>
<title>square8</title>
<script src="ttt.js"></script>
</head>
<body onfocus="playermoves();">

</body>
</html>

请问这段代码有什么问题?
playermoves()是ttt.js里面一个函数

总是报错说:第5行缺少 “)”
第6行缺少对象
...全文
49 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
心云意水 2003-12-14
  • 打赏
  • 举报
回复
function isblank(n)
{
if(owns("player",n)||owns("computer",n)<-晕!很明显少个括号……
{
return false;
}
return true;
}
darkdragon1981 2003-12-13
  • 打赏
  • 举报
回复
ttt.js如下:


function isblank(n)
{
if(owns("player",n)||owns("computer",n)
{
return false;
}
return true;
}

function owns(who,i)
{
var fr=parent.parent.frames[1];
var doc=fr.document;
var field=doc.forms[0].element[i];
if(field==null||field.value=who)
{
return true;

}
Else
{
return false;
}
}

function setowner(who,n)
{
var fr=parent.parent.frames[1];
var doc=fr.document;
var field=doc.forms[0].element[n];
field.value=who;


}

function tictactoe(who,n1,n2,n3)
{
if(owns(who,n1)&&owns(who,n2)&&owns(who,n3))
{
var color=parent.frames[0].document.bgcolor;
for(var i=0;i<9;i++)
{
parent.frames[i].document.bgcolor="black";
parent.frames[n1].document.bgcolor=color;
parent.frames[n2].document.bgcolor=color;
parent.frames[n3].document.bgcolor=color;
return ture;

}
}
return false;

}

function istictactoe(who)
{
if(tictactoe(who,0,1,2))
return true;
if(tictactoe(who,3,4,5))
return true;
if(tictactoe(who,6,7,8))
return true;
if(tictactoe(who,0,3,6))
return true;
if(tictactoe(who,1,4,7))
return true;
if(tictactoe(who,2,5,8))
return true;
if(tictactoe(who,0,4,8))
return true;
if(tictactoe(who,2,4,6))
return true;
return false;
}

function computermoves()
{
var moved=false;
while(!moved)
{
var newmove=Math.round(9*Math.random());
if (isblank(newmove))
{
setowner("computer",newmove);
var fr=parent.frames[newmove];
fr.location.href="x.html";
moved=true;

}
}

}

function playermoves()
{
if(isblank(cell))
{
setowner("player",cell);
location.href="o.html";
if(!istictactoe("player"))
computermoves();
istictactoe("computer");

}
}
xzq686 2003-12-13
  • 打赏
  • 举报
回复
你的ttt.js 有问题
<body onload="playermoves();">这样也行!

chenyubang 2003-12-13
  • 打赏
  • 举报
回复
把ttt.js贴出来看看吧,不然诊断不了
zhongmao 2003-12-12
  • 打赏
  • 举报
回复
是js文件有错误!

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧