求大神帮忙看一下问题所在!
<!DOCTYPE html><html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>打字游戏</title>
<style>
.divStyle{
width:50px;
height:50px;
background-color:#000;
color:#FFF;
font-family:"微软雅黑";
font-size:30px;
text-align:center;
line-height:50px;
position:absolute;
}
</style>
<script type="text/javascript">
var flg = true;
function createDiv(){
var info = new Array();
for(var i=65,j=0;i<=90;i++,j++){
info[j] = String.fromCharCode(i);//获取字母相对应的数字
}
//alert(info);
var div = document.createElement("div");
div.setAttribute("class","divStyle");
div.innerHTML =info[Math.floor(Math.random()*info.length)];
//系统的总宽度
var sysWidth = Math.round(Math.random()*(window.innerWidth-50));
div.style.left = sysWidth+"px";
div.style.top = "0px";
document.body.appendChild(div);
if(flg){
moveDiv();
flg = false;
}
window.setTimeout(createDiv,1000);
}
function moveDiv(){
var divs = document.getElementsByTagName("div");
for(var i=0;i<=divs.length-1;i++){
var divTop = divs[i].style.top;
var newTop = parseFloat(divTop.substring(0,divTop.length-2))+10;
divs[i].style.top = newTop+"px";
var sysHeight = window.innerHeight-50;
if(newTop>=sysHeight){
document.body.removeChild(divs[i]);
}
}
window.setTimeout(moveDiv,10);
}
function begin(){
window.onload = createDiv;
}
function end(){
window.location.reload();
}
//获取键盘按键的ASSII
window.onkeyup= function(event){
var key = event.keyCode;
var divInfo = String.fromCharCode(key);
var divs = document.getElementsByTagName("div");
for(var i=0;i<=divs.length-1;i++){
if(divInfo == divs[i].innerHTML){
document.body.removeChild(divs[i]);
break;
}
}
}
</script>
</head>
<body>
<script>
var input = document.createElement("INPUT");
input.setAttribute("type","button");
input.setAttribute("value","开始游戏");
input.setAttribute("onclick","begin();");
document.body.appendChild(input);
</script>
</body>
</html>