pc.yzdown.com 脚本展示
猜数字游戏
请先想好一个数字(0到63之间的数),然后开始,按照提示作相应问答,系统就能猜出那个数
以下代码加入<head>区域
<script language="Javascript"> <!-- function selectAll(theField){ var tempval=eval("document."+theField) tempval.focus() tempval.select() } //--> </script>
以下代码加入<body>区域
<script language="JavaScript"> <!-- Begin var cards = new Array(6); var play = 0; var cn = 0; var ttl = 0; cards[1] = " CARD ONE \n 1 3 5 7 9 11 13 15 \n 17 19 21 23 25 27 29 31 \n 33 35 37 39 41 43 45 47 \n 49 51 53 55 57 59 61 63"; cards[2] = " CARD TWO \n 2 3 6 7 10 11 14 15 \n 18 19 22 23 26 27 30 31 \n 34 35 38 39 42 43 46 47 \n 50 51 54 55 58 59 62 63"; cards[3] = " CARD THREE \n 4 5 6 7 12 13 14 15 \n 20 21 22 23 28 29 30 31 \n 36 37 38 39 44 45 46 47 \n 52 53 54 55 60 61 62 63"; cards[4] = " CARD FOUR \n 8 9 10 11 12 13 14 15 \n 24 25 26 27 28 29 30 31 \n 40 41 42 43 44 45 46 47 \n 56 57 58 59 60 61 62 63"; cards[5] = " CARD FIVE \n 16 17 18 19 20 21 22 23 \n 24 25 26 27 28 29 30 31 \n 48 49 50 51 52 53 54 55 \n 56 57 58 59 60 61 62 63"; cards[6] = " CARD SIX \n 32 33 34 35 36 37 38 39 \n 40 41 42 43 44 45 46 47 \n 48 49 50 51 52 53 54 55 \n 56 57 58 59 60 61 62 63"; var ccol = new Array("","#FF7777","Green","Blue","Gray","Red","Black"); var knos = new Array("",1,2,4,8,16,32); function Nextcard() { cn++; if(cn == 7) End(); else { document.x.card.value=cards[cn]; document.x.card.style.backgroundColor=ccol[cn]; document.x.text.value="你想的数字在上面吗?"; } } function Restart() { play=0; cn=0; ttl=0; document.x.card.style.backgroundColor = "#FFFFFF"; document.x.card.style.color = "#000000"; document.x.card.value = "请先想好一个数字(0到63之间的数),然后开始,按照提示作相应问答,系统就能猜出那个数."; document.x.text.value = "按开始键"; document.x.stbt.value = "开始"; } function Yes() { ttl = ttl + knos[cn]; Nextcard(); } function Start() { document.x.card.style.color = "White"; document.x.stbt.value = "重新开始"; play = 1; Nextcard(); } function End() { play = 2; if(ttl < 10) ttl = " " + ttl; ttl = " " + ttl; var one = ttl.charAt(1); var two = ttl.charAt(2); document.x.card.value = "\n 你想的那个数字是 : \n -- [ "+one+" "+two+" ] --"; document.x.card.style.color = "Red"; document.x.text.value = "按开始键重新开始"; } function click() { event.cancelBubble = true; event.returnValue = false; } document.oncontextmenu = click; // End --> </script> <form name="x"> <center> <table border="0"> <tr> <td> <center> <textarea name="card" rows="5" cols="25">请先想好一个数字(0到63之间的数),然后开始,按照提示作相应问答,系统就能猜出那个数</textarea> </center> </td> </tr> <tr> <td> <center> <input type="text" size="36" name="text" value="按开始" style="FONT-SIZE: 9pt"> </center> </td> </tr> <tr> <td> <center> <input type="button" value="是的" onClick="if(play==1) Yes()" style="FONT-SIZE: 9pt" name="button"> <input type="button" value="不是" onClick="if(play==1) Nextcard()" style="FONT-SIZE: 9pt" name="button"> <input type="button" name="stbt" value="开始" onClick="if(play==0) Start(); else Restart()" style="FONT-SIZE: 9pt"> </center> </td> </tr> </table></center> </form>
可能某段代码会由于COPY时的不小心以至不能正常显示,如发现此情况,请告知 pc.yzdown.com