链接类

VML

按钮类

标题类

表单类

表格类

菜单类

窗口类

对象类

滚动条

键盘类

框架类

例子类

模拟类

日期类

色彩类

鼠标类

数学类

图片类

文字类

下拉框

样式类

游戏类

状态栏

资料类

字幕类

其它类

 ·测测反应速度
 ·模拟跳舞
 ·乒乓球
 ·24点
 ·射击
 ·敲砖头
 ·测试游戏
 ·贪吃蛇
 ·数格排序
 ·十字定全局
您当前位置:好素材首页 -> 网页特效 -> 游戏类
查看信息

猜数字
好素材网 www.HaoSc.com 02月22日 11:49

[查看演示]  源码如下
----------------------------------------------------------
<html>
<head>
<title>Guess a Number-www.51windows.Net</title>
<script LANGUAGE="JavaScript">
var num = Math.floor(Math.random() * 100) + 1;
var tries = 0;
function guessit() {
var guess = document.form1.guess1.value;
tries++;
status = "Tries: " + tries;
if (guess < num)
document.form1.hint.value = "不对, 猜高点.";
if (guess > num)
document.form1.hint.value = "不对, 猜低点.";
if (guess == num) {
window.alert("正确! 恭喜你只用了" + tries + " 次.");
location.reload();
}
if (tries == 10) {
window.alert("对不起,时间到. 答案是: " + num);
location.reload();
}
}
</script>
</head>
<body BGCOLOR=336699>
<h1><CENTER><FONT SIZE=15 COLOR=RED >猜数字</FONT></CENTER></h1>
<hr>
<p><CENTER><FONT SIZE=5 COLOR=BLUE >这个数在100以内. 你只有10次机会.</FONT></CENTER></p>
<form NAME="form1">
<input TYPE="text" SIZE=25 NAME="hint" VALUE="填入你的数字.">
<br>
<b>猜吧:</b>
<input TYPE="text" NAME="guess1" SIZE="5">
<input TYPE="BUTTON" VALUE="确定" onClick="guessit();">
<input TYPE="BUTTON" VALUE="确定" onClick="ss();">
</form>
</body>
</html>

<div style="position: absolute; top: 10; right: 10; width: 148; height: 18;cursor:hand">
<input type="button" name="Button" value="查看源代码" onClick= 'window.location = "view-source:" + window.location.href'></div>


此信息共 1 页 [1]