易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

[JAVASCRIPT] IFRAME VS AJAX 异步提交

在ajax没出来之前,一直是用iframe实现的无刷新请求。
主要的原理是:
使用js创建一个隐藏的iframe
把要提交的表单的target属性指向1中生成的iframe
在请求的页面中回调父页面的方法
这样就实现了一个简单的“异步提交”
看起来和ajax一样的效果,那为什么还要有ajax,我们来比较下:(以下把ajax技术称为X ......

javascript event对象 与 jquery event 解析(转)

转自:http://www.cnblogs.com/mslove/
描述
event代表事件的状态,例如触发event对象的元素、鼠标的位置及状态、按下的键等等。
event对象只在事件发生的过程中才有效。
event的某些属性只对特定的事件有意义。比如,fromElement 和 toElement 属性只对 onmouseover 和 onmouseout 事件有意义。
例子
下面的例子检查 ......

href=“#”与href=“javascript:void(0)”区别

使用过ajax的都常见这样的代码:
<a href="javascript:doTest2();void(0);" mce_href="javascript:doTest2();void(0);">here</a>
但这儿的void(0)究竟是何含义呢?
Javascript中void是一个操作符,该操作符指定要计算一个表达式但是不返回值。
void 操作符用法格式如下:
1. javascript:void (expres ......

[JAVASCRIPT] this 对象

看了很多javascrip代码,发现很多地方用到了this这个对象,那这个到底是什么东西阿?
先让我们来理解一个概念:
在javascript会有一个上下文的概念,任何一个对象无论是Object 还是function 都会有一个专有的上下文对象,也可以理解为它自己的拥有者。
那么我们很容易想到这个拥有者,必然有个终点,那就是window对象。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号