js的打字游戏的例子
来源:互联网 发布:浙大gpa算法 编辑:程序博客网 时间:2024/05/01 01:17
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'c.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
var score = 0;
//产生一个字母
function getEnglishChar()
{
var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var ch = str.charAt(Math.round(Math.random()*35));
return ch;
}
//将字母写到屏幕上
function display()
{
var ch = getEnglishChar();
var lab = document.createElement("label");
lab.innerHTML = ch;
with(lab.style)
{
left = Math.round(document.body.clientWidth * Math.random());
top = "0px";
position = "absolute";
fontSize = "20px";
color = "green";
}
document.body.appendChild(lab);
}
//字母掉下来
function down()
{
var chs = document.getElementsByTagName("label");
if(chs != null)
{
for(i = 0; i < chs.length; i++)
{
chs[i].style.top = parseInt(chs[i].style.top) + 20 +"px";
if(chs[i].style.offsetHeight + chs[i].style.offsetTop >= document.body.clientHeight)
{
document.body.removeChild(chs[i]);
score--;
}
alert(score);
}
}
}
var s1 = setInterval("display()",1000);
var s2 = setInterval("down()",100);
//alert("asdas");
document.onkeyup = function(event)
{
var str = document.getElementsByTagName("label");
for(i = 0; i < str.length; i++)
{
var ch = str[i].innerHTML;
e = event?event:window.event;
//alert(ch.charCodeAt(0)==e.keyCode);
//alert();
if(ch.charCodeAt(0) == e.keyCode)
{
document.body.removeChild(str[i]);
score++;
}
}
}
function end()
{
clearInterval(s1);
clearInterval(s2);
//alert("你的得分是:"+ score);
/*var chs = document.getElementsByTagName("label");
for(i = 0; i < chs.length; i++)
{
document.body.removeChild(chs[i]);
}*/
alert(score);
document.body.innerHTML = "";
}
</script>
</head>
<body>
<input type="button" value="停止" onclick="end()"/>
</body>
</html>
- js的打字游戏的例子
- js+canvas+html 写的打字游戏
- JavaScript写的打字游戏
- 简单的Java打字游戏
- 自己写的一个打字游戏
- turbo C 下的打字游戏
- turboC下打字游戏的界面编写
- 用C语言实现的打字游戏
- javascript实现的简单打字游戏
- jQuery 写的简单打字游戏
- 简单的打字游戏心得体会(代码)
- Java 写的打字游戏,不喜勿喷
- 玩一组奇妙的打字游戏
- jQuery实现简单的打字游戏功能
- Qt实现一个简单的打字游戏
- 原生JS写打字游戏
- JS实现简单的打字效果
- 求助~~js做的打字小游戏
- 域管理环境中进行软件的推送安装
- 天天记录 - Android AsyncTask 缺陷
- 离散数学中文—外文名词对照表
- ACRush 楼天成回忆录
- 域环境下的软件发布和指派
- js的打字游戏的例子
- POJ 1305 勾股数组
- mount iso文件
- ArcGIS Engine10.0轻松入门级教程(5)——ArcEngine10.0三维开发
- js的百度的下拉框的例子
- (一)solr4.0 solr4.0,solr4.2,solr4.3, replica collection core shard slice 概念阐述
- DG3.1——逻辑备库说明
- Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/RixinWeb,J2EEApplication=non
- 第05章 数组 13 练习 11