<!DOCTYPE html PUBLIC "
<html xmlns="
<head>
<meta http
<title>簡易計算機</title>
</head>
<body>
<input type="button" id="result" name="result" onclick="checknum()" value="進入數字游戲
<script>
//獲取隨機數
function GetRandomNum(Min
{
var Range = Max
var Rand = Math
return(Min + Math
}
//獲取文本框內容
function checknum(){
var num = GetRandomNum(
alert("dnhgn");
var i;
for(i=
var nums=prompt("猜
if(i==
if(nums==num){
alert("恭喜答對了
break;
}else{
if(nums<num){
document
}else{
document
}
}
}
if(i>
if(nums==num){
alert("恭喜答對了");
break;
}else{
if(nums<num){
document
}else{
document
}
}
}
if(i==
if(nums!=num){
document
return false;
}
}
}
}
</script>
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20318.html