自己写的javascript五子棋
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>five-in-a-raw</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
<!--
table{text-align: center;font-size: 20px;cursor: hand;empty-cells: show;table-layout: fixed;}
-->
</style>
</head>
<script type="text/javascript">
<!--
function FiveRawGame(){
this.redChess="<font color=\"red\">X</font>";
this.blackChess="<font color='black'>O</font>";
//初始化棋盘和数据
this.init=function(){
var str="<table width=\"600\" height=\"600;\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" >";
for(var i=0;i<25;i++){
str+="<tr height='7'>";
for(var j=0;j<25;j++){
str+="<td id='r"+i+"c"+j+"' onclick=\"FiveRawGame.chess("+i+","+j+")\" onmouseover=\"FiveRawGame.showMsg("+i+","+j+")\"> </td>";
}
str+="</tr>";
}
str+="</table>";
document.getElementById("main").innerHTML=str;
this.allGrids=new Array();
for(var a=0;a<25;a++){
this.allGrids[a]=new Array();
}
for(var i=0;i<25;i++){
for(var j=0;j<25;j++){
this.allGrids[i][j]=new grid(i,j,"O");
}
}
this.isChess=true;
this.redArr=new Array();
this.blackArr=new Array();
this.allArr=new Array();
相关文档:
最近编写Javascript代码。起初没管那么多。一阵狂写。代码写得差不多了。结果上百K文件几十个。当然 没办法需要压缩了。为了速度。
找压缩工具。弄了下。结果错误一大堆。最后才发现是自己写的代码不规范导致的。检查了半天修正了几十个地方。终于能压缩了。
下面总结下需要注意的地方
1、对象结尾 function结尾 最 ......
在Web开发中,会遇到从一页(父页)导向另一页(子页),并且要求“返回”父页的情况,在这里如果用ASP.NET提供的 Response.Redirect()方法,往往不会达到理想的效果,例如:返回后,重新加载了页面,无法保存导向子页前的状态,等等,在这里我就介绍 一下如何使用JavaScript中history.go()函数来实现返回 ......
<script>setTimeout("redirect('<?=$url_forward?>');", <?=$ms?>);</script>
设置分页:$page $pagesize $offset = ($page-1)*$pagesize;
$limit = "limit $offset,$pagesize" ......
Dynamic Scopes 动态作用域
Both the with statement and the catch clause of a try-catch statement, as well as a function containing eval_r(), are all considered to be dynamic scopes. A dynamic scope is one that exists only through execution of code and therefore cannot be det ......
Cloning Nodes 节点克隆
Another way of updating page contents using DOM methods is to clone existing DOM elements instead of creating new ones—in other words, using element.cloneNode() (where element is an existing node) instead of document.createElement().
&nbs ......