易截截图软件、单文件、免安装、纯绿色、仅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 事件有意义。
例子
下面的例子检查 ......

Javascript Closures

Javascript Closures
Introduction
The Resolution of Property Names on Objects
Assignment of Values
Reading of Values
Identifier Resolution, Execution Contexts and Scope Chains
The Execution Context
Scope chains and [[scope]]
Identifier Resolution
Closures
Automatic Garbage Collecti ......

JavaScript获得上一页地址

在JavaScript中利用document.referrer可以获得跳转前上一页的地址,其实在诸如Asp,PHP等语言中都可以获得这个参数,只不过写法不同,然后可以判断是哪里来的请求从而做一些处理.但是JS中的document.referre只能获得<a>标签传过来的参数.看代码
a.html
<html>
<head>
<title>测试</title> ......

[转]JavaScript中的正则表达式解析

正则表达式是一个描述字符模式的对象。
  JavaScript的RegExp对象和String对象定义了使用正则表达式来执行强大的模式匹配和文本检索与替换函数的方法.
  在JavaScript中,正则表达式是由一个RegExp对象表示的.当然,可以使用一个RegExp()构造函数来创建RegExp对象,也可以用
JavaScript
1.2中的新添加的一个特殊语法 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号