易截截图软件、单文件、免安装、纯绿色、仅160KB

JavaScript贪吃蛇

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>贪食蛇</title></head>
<body>
<mce:style type="text/css"><!--
.table_back{width:320px;height:320px;border-bottom:1px solid black;border-right:1px solid black;}
.floor{border-left:1px solid black;border-top:1px solid black;font-size:1px;}
--></mce:style><style type="text/css" mce_bogus="1">.table_back{width:320px;height:320px;border-bottom:1px solid black;border-right:1px solid black;}
.floor{border-left:1px solid black;border-top:1px solid black;font-size:1px;}</style>
<mce:script type="text/javascript"><!--
/*--
标题:简单的贪吃蛇
设计:王集鹄
博客:http://blog.csdn.net/zswang
日期:2010年1月22日
--*/
function Snake(options) {
var self = this;
options = options || {};
this.colCount = options.colCount || 20;
this.rowCount = options.rowCount || 20;
this.parent = options.parent || document.body; // 容器
this.speed = options.speed || 200; // 移动间隔时间
this.initLength = options.initLength || 3; // 初始长度

this.button_replay = document.createElement("input");
this.button_replay.type = "button";
this.button_replay.value = "replay";
this.button_replay.onclick = function() {
self.replay();
};
this.parent.appendChild(this.button_replay);
this.table_back = document.createElement("table");
this.table_back.className = "table_back";
this.table_back.cellPadding = "0px";
this.table_back.cellSpacing = "0px";
this.playing = false; // 是否在进行中
this.floors = {}; // 矩阵地板矩阵 [y,x]
for (var i = 0; i < this.rowCount; i++) {
var tr = this.table_back.insertRow(-1);
for (var j = 0; j < this.colCount; j++) {
var td = tr.insertCell(-1);
td.classNa


相关文档:

asp.net中调用javascript自定义函数的方法总结

通常javascript代码可以与HTML标签一起直接放在前端页面中,但如果JS代码多的话一方面不利于维护,另一方面也对搜索引擎不友好,因
为页面因此而变得臃肿;所以一般有良好开发习惯的程序员都会把javascript代码放到独立的js文件中,其他页面通过引入该js文件来使用相应的
javascript代码。
今天在做一个小新闻系统的管理 ......

javascript操作DOM

1.创建节点并添加内容:使用的方法:createElement和createTextNode
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>HTML DOM</title>
&nbs ......

[JAVASCRIPT] this 对象

看了很多javascrip代码,发现很多地方用到了this这个对象,那这个到底是什么东西阿?
先让我们来理解一个概念:
在javascript会有一个上下文的概念,任何一个对象无论是Object 还是function 都会有一个专有的上下文对象,也可以理解为它自己的拥有者。
那么我们很容易想到这个拥有者,必然有个终点,那就是window对象。 ......

JavaScript中的空类型

转载理由:短小精悍。
来源:互联网
一 Undefined 类型
只有一种值 undefined
以下三种情况typeof 返回类型为undefined
1. 当变量未初始化时
2. 变量未定义时
3. 函数无明确返回值时(函数没有返回值时返回的都是undefined)
undefined 并不等同于未定义的值
typeof 并不真正区分是否是未定义
看以下示例 ......

javascript中的null和undefined

javascript中的null和undefined
本文装载网络,版权归原作者所有。
null :表示无值;
undefined : 表示一个未声明的变量,
                或已声明但没有赋值的变量,
          &nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号