当前位置:首页 > 网络编程 > WEB编程 > JSP > 测试点击速度

测试点击速度

点击次数:30 次 发布日期:2008-11-22 13:34:35 作者:源代码网
源代码网推荐

脚本说明:
第一步:把如下代码加入<head>区域中
<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Tomer Shiran

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var total = 0
var play = false
function display(element) {
var now = new Date()
if (!play) {
play = true
startTime = now.getTime()}
if (now.getTime() - startTime > 20000) {
element.checked = !element.checked
return
}
 if (element.checked)
total++
else
total--
element.form.num.value = total
}
function restart(form) {
total = 0
play = false
for (var i = 1; i <= 100; ++i) {
 form.elements[i].checked = false
   }
}
// End -->
</SCRIPT>

第二步:把如下代码加入<body>区
<CENTER>Test your skill.  How many boxes can 
you check in 20 seconds?</CENTER>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
document.write("<FORM><CENTER>")
document.write("<INPUT TYPE="text" VALUE="0" ");
document.write("NAME="num" SIZE=10 onFocus="this.blur()"><BR>")
document.write("<HR SIZE=1 WIDTH=40%>")
for (var i = 0; i < 10; ++i) {
for (var j = 0; j < 10; ++j) {
document.write("<INPUT TYPE="checkbox" ");
document.write("onClick="display(this)">")}
document.write("<BR>")}
document.write("<HR SIZE=1 WIDTH=40%>")
document.write("<INPUT TYPE="button" VALUE="restart" ");
document.write("onClick="restart(this.form)">")
document.write("</CENTER></FORM>")
// End -->
</SCRIPT>

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华