脚本说明: 第一步:把如下代码加入<head>区域中 <SCRIPT LANGUAGE=JavaScript> var js_mult= var js_mult= var js_m= var js_m= var js_iseed= var js_iseed= var js_iseed= function random(n) { if (js_iseed == ) { now = new Date() js_iseed = nowgetHours() + nowgetMinutes() * + nowgetSeconds() * } js_iseed = js_iseed / js_m js_iseed = js_iseed % js_m var tmp = (((js_iseed * js_mult + js_iseed * js_mult) % js_m) * js_m + (js_iseed * js_mult)) % js_m js_iseed = (tmp + ) % js_m return (Mathfloor((js_iseed/js_m) * n)) } var myNumber = var nGuesses = function guessnum() { var response var num = parseInt(documentforms[]guessvalue) documentforms[]guessvalue = num // visual feedback in case of NaN nGuesses++ // increase the guess count response = 哦你猜的数 if (num < myNumber) response = response + 太小了 if (num > myNumber) response = response + 太大了 if (num == myNumber) { response = response + 对了!!你猜到我了! nGuesses = myNumber = random()+ } documentforms[]resultvalue=response documentforms[]guessesvalue=nGuesses documentforms[]guessfocus() documentforms[]guessselect() return true } function giveup() { var response nGuesses = response = 我的数字是 + myNumber + 想猜我的新数吗? myNumber = random()+ documentforms[]resultvalue=response documentforms[]guessesvalue=nGuesses documentforms[]guessfocus() documentforms[]guessselect() } </SCRIPT> <font size= color=#FF> 我手中有一个数它的范围在~之间你能猜到它是几吗?</font></b><font size=> </font> <SCRIPT> myNumber = random()+ nGuesses = </SCRIPT> <FORM onSubmit=guessnum(); return false> 填入你猜的数: <INPUT TYPE=text NAME=guess SIZE=> <INPUT TYPE=button VALUE= 我来猜 onClick=guessnum()> <INPUT TYPE=button VALUE= 放弃 onClick=giveup()> </FORM> <FORM> 你已猜了: <INPUT TYPE=text NAME=guesses SIZE=>次 提示信息: <INPUT TYPE=text NAME=result SIZE=> </FORM> 第二步:把<body>区域中的内容改为: <body bgcolor=#fefd onLoad=documentforms[]guessfocus(); documentforms[]guessselect()> |