29、打字速度测试效果。

程序代码:
<SCRIPT LANGUAGE="JavaScript">
<!--
msg = new Array("Practicing with your typing can greatly help your overall computer skills.",
"A new computer is sold in the US every hour!",
"When do birds migrate from North to South?",
"Perplexing phrases, like this one, are tougher to type.")
word = 10
function s() {
msg = new Array("Computers are the medium of the future.",
"Can you type this phrase rather quickly?",
"Who is the President of the US?",
"I believe that you can type well!")
word = 7
}
function m() {
msg = new Array("Practicing with your typing can greatly help your overall computer skills.",
"A new computer is sold in the US every hour!",
"When do birds migrate from North to South?",
"Perplexing phrases, like this one, are tough to type.")
word = 10
}
function e() {
msg = new Array("If you can correctly, and quickly, type this perplexing sentence, you are one superb typist!",
"You are one superb typist if you can correctly, and quickly, type this long phrase.",
"I believe you're a good typist, so I believe you will correctly copy this statement!",
"Because this is not a fairly simple phrase, could you swiftly, and precisely, copy it?")
word = 15
}
function beginnow() {
randNum = Math.floor((Math.random() * 10)) % 4
msgType = msg[randNum]
day = new Date();
startType = day.getTime();
document.theForm.given.value = msgType
document.theForm.typed.focus();
}
function cheat() {
alert("对不起,这里的内容你不能改变!!");
document.theForm.typed.focus();
}
function stopnow() {
dayTwo = new Date();
endType = dayTwo.getTime();
totalTime = ((endType - startType) / 1000)
spd = Math.round((word/totalTime) * 60)
if (document.theForm.typed.value == document.theForm.given.value) {
alert("n你输入了 " + word + " 个字符,在 " + totalTime + " 秒内, 速度为每秒钟 " + spd + " 个字符!")
}
else {
alert("你输入有错,但是你每分钟输入 " + spd + " 个字符.")
}
}
// -->
</SCRIPT>
<body>
<FORM name="theForm">
<TABLE BORDER=3>
<TR>
<TD>你是个...</TD>
<TD align=center><input type=radio name="sme" value="Beginner" onClick="s()" checked>初级
<input type=radio name="sme" value="Novice" onClick="m()">中级
<input type=radio name="sme" value="Expert" onClick="e()">高级</TD>
</TR>
<TR><TD colspan=2><BR>
<center><input type=button value="开始测试" name="start" onClick="beginnow()"></center><BR>
<textarea name="given" cols=53 rows=3 wrap=on onFocus="cheat()"></textarea></TD>
</TR>
<TR><TD colspan=2><input type=text name="typed" size=49><input type=button value="结束" name="stop" onClick="stopnow()"></TD>
</TR>
</TABLE>
</FORM>
</body>