有趣的JavaScript小程序

时间:2022-01-04 12:21:20
 <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>倒计时</title>
</head> <script type="text/javascript">
<!--
h= 0
m= 0
s= 30 function cal()
{
--s
if (s < 0)
{
--m
s= 59
}
if (m < 0)
{
--h
m= 59
}
if(h>=0) document.aa.t1.value= h+": "+m+": "+s
else {
alert("考试结束,恭喜你撑到了最后!")
num= 8
s= "Do you want to anymore? \n "
hehe= "0.0 "
haha= "~.~ "
for(i=1; i<=num; ++i) {
str= s
for(j=1; j<=i; ++j) str= str+ ( Math.random( )< 0.5 ? hehe: haha )
alert ( str )
}
return
}
setTimeout("cal()",200)
}
//-->
</script> <body bgcolor= #33ffff>
<form name="aa">
距离考试结束还剩下:
<input type=text name="t1">
</form>
<SCRIPT LANGUAGE="JavaScript">
<!--
cal()
//-->
</SCRIPT>
</body>
</html>