<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312"/>
</head>
<body background="images/34.png">
<table width="650">
<tr>
<th width="239" height="21" align="right" style=" color:#CC0000"><h2>益智游戏:</h2></th>
<th width="399" align="left" style=" color:#CC0000"><h2>猜数字</h2></th>
</tr>
</table>
<div style="padding-top:70px; padding-left:120px; background-image:url(images/12.png); margin-left:125px; width:650; height:420;">
<!--单位:秒-->
<table width="428">
<tr>
<th width="103" rowspan="5"><p>难度选择:<br/>
<input type='radio' name='level' checked="checked" value="0">初级<br/>
<input type='radio' name='level' value="1">中级<br/>
<input type='radio' name='level' value="2">高级<br/>
<input type='radio' name='level' value="3">骨灰级<br/>
<input type="button" value="开始游戏" onClick="start()"/>
<input type="button" value="暂停游戏" onClick="stop()"/>
</th>
<th width="338" align="left">消耗了时间: <span id="time_txt"> 0</span>s </th>
</tr>
<tr><th align="left">剩余时间:<span id="endtime">120</span></th></tr>
<script type="text/javascript" src="a.js"></script> <tr><th align="left">猜了: <span id="i_txt"> 0</span>次 </th>
</tr>
<tr><th align="left">请输入数字:
<input type="text" value="" id="num_input"/>
<input type="button" value="确定" onClick="checkIfRight()"/></th></tr>
<tr><th align="left"> 提示:
<li>这数字是一个<span id="len_txt"> 0</span>位数</li>
<li>猜正确位置的数的个数:<span id="j"></span></li>
<li>猜正确的数的个数:<span id="q"></span></li></th></tr>
</table>
<p>
<b>最后得分:<span id="score"> 0</span>分</b></p>
<table>
<tr><th width="100"><h3><a href="game2.html" target="body" style=" text-decoration:none" >重玩</a></h3></th>
<th width="100"><h3><a onClick="window.open(document.location,'big','fullscreen=yes')">全屏</a></h3></th>
<th width="100"><h3><a onClick="window.close()">退出</a></h3></th>
</tr>
</table>
</div>
<div style="margin-left:125px; width:650">
<embed src="music.mp3" autostart="true" width="650" height="40" loop="-1">
</div>
</body>
<script type="text/javascript" src="b.js"></script>
</html> javascript:b.jsvar total_times = 0;
var i = 0;
var score = 1000000;
function start(){
var ifstop = false;
setTimeout("updateTime()",1000);
var num = parseInt(9999*Math.random());
var nums = num+"";
document.getElementById('len_txt').innerText = nums.length;
var a = num/1000;
var b = num%1000/100;
var c = num%1000%100/10;
var d = num%1000%100%10;
var aa = Math.floor(a);
var bb = Math.floor(b);
var cc = Math.floor(c);
}
function updateTime(){
if(!ifstop){
setTimeout("updateTime()",1000);
total_times++;
}
document.getElementById('time_txt').innerText = total_times;
}
function checkIfRight(){
var numinput = document.getElementById('num_input').value;
i++;
document.getElementById('i_txt').innerText = i;
var a1 = numinput/1000;
var b1 = numinput%1000/100;
var c1 = numinput%1000%100/10;
var d1 = numinput%1000%100%10;
var a2 = Math.floor(a1);
var b2 = Math.floor(b1);
var c2 = Math.floor(c1);
var j=0;
var q=0;
if(num != numinput){
if(aa==a2){
j++;
}
if(bb==b2){
j++;
}
if(cc==c2){
j++;
}
if(d==d1){
j++;
}
document.getElementById('j').innerText = j;
if(aa==b2||aa==c2||aa==d1){
q++;
}
if(bb==a2||bb==c2||bb==d1){
q++;
}
if(cc==a2||cc==b2||cc==d1){
q++;
}
if(d==a2||d==b2||d==c2){
q++;
}
document.getElementById('j').innerText = j;
document.getElementById('q').innerText = q;
alert('猜错了,请重新输入!');
}
else{
ifstop = true;
score = 1000000 - 30000*i - total_times*1500;
document.getElementById('score').innerText = score;
alert('恭喜你,猜对了,您一共猜了:'+i+'次,消耗了:'+total_times+'s\n本次得分:'+score);
}
if(i>=20){alert('对不起,您已经没有机会了,正确答案是'+num);}
}
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312"/>
</head>
<body background="images/34.png">
<table width="650">
<tr>
<th width="239" height="21" align="right" style=" color:#CC0000"><h2>益智游戏:</h2></th>
<th width="399" align="left" style=" color:#CC0000"><h2>猜数字</h2></th>
</tr>
</table>
<div style="padding-top:70px; padding-left:120px; background-image:url(images/12.png); margin-left:125px; width:650; height:420;">
<!--单位:秒-->
<table width="428">
<tr>
<th width="103" rowspan="5"><p>难度选择:<br/>
<input type='radio' name='level' checked="checked" value="0">初级<br/>
<input type='radio' name='level' value="1">中级<br/>
<input type='radio' name='level' value="2">高级<br/>
<input type='radio' name='level' value="3">骨灰级<br/>
<input type="button" value="开始游戏" onClick="start()"/>
<input type="button" value="暂停游戏" onClick="stop()"/>
</th>
<th width="338" align="left">消耗了时间: <span id="time_txt"> 0</span>s </th>
</tr>
<tr><th align="left">剩余时间:<span id="endtime">120</span></th></tr>
<script type="text/javascript" src="a.js"></script> <tr><th align="left">猜了: <span id="i_txt"> 0</span>次 </th>
</tr>
<tr><th align="left">请输入数字:
<input type="text" value="" id="num_input"/>
<input type="button" value="确定" onClick="checkIfRight()"/></th></tr>
<tr><th align="left"> 提示:
<li>这数字是一个<span id="len_txt"> 0</span>位数</li>
<li>猜正确位置的数的个数:<span id="j"></span></li>
<li>猜正确的数的个数:<span id="q"></span></li></th></tr>
</table>
<p>
<b>最后得分:<span id="score"> 0</span>分</b></p>
<table>
<tr><th width="100"><h3><a href="game2.html" target="body" style=" text-decoration:none" >重玩</a></h3></th>
<th width="100"><h3><a onClick="window.open(document.location,'big','fullscreen=yes')">全屏</a></h3></th>
<th width="100"><h3><a onClick="window.close()">退出</a></h3></th>
</tr>
</table>
</div>
<div style="margin-left:125px; width:650">
<embed src="music.mp3" autostart="true" width="650" height="40" loop="-1">
</div>
</body>
<script type="text/javascript" src="b.js"></script>
</html> javascript:b.jsvar total_times = 0;
var i = 0;
var score = 1000000;
function start(){
var ifstop = false;
setTimeout("updateTime()",1000);
var num = parseInt(9999*Math.random());
var nums = num+"";
document.getElementById('len_txt').innerText = nums.length;
var a = num/1000;
var b = num%1000/100;
var c = num%1000%100/10;
var d = num%1000%100%10;
var aa = Math.floor(a);
var bb = Math.floor(b);
var cc = Math.floor(c);
}
function updateTime(){
if(!ifstop){
setTimeout("updateTime()",1000);
total_times++;
}
document.getElementById('time_txt').innerText = total_times;
}
function checkIfRight(){
var numinput = document.getElementById('num_input').value;
i++;
document.getElementById('i_txt').innerText = i;
var a1 = numinput/1000;
var b1 = numinput%1000/100;
var c1 = numinput%1000%100/10;
var d1 = numinput%1000%100%10;
var a2 = Math.floor(a1);
var b2 = Math.floor(b1);
var c2 = Math.floor(c1);
var j=0;
var q=0;
if(num != numinput){
if(aa==a2){
j++;
}
if(bb==b2){
j++;
}
if(cc==c2){
j++;
}
if(d==d1){
j++;
}
document.getElementById('j').innerText = j;
if(aa==b2||aa==c2||aa==d1){
q++;
}
if(bb==a2||bb==c2||bb==d1){
q++;
}
if(cc==a2||cc==b2||cc==d1){
q++;
}
if(d==a2||d==b2||d==c2){
q++;
}
document.getElementById('j').innerText = j;
document.getElementById('q').innerText = q;
alert('猜错了,请重新输入!');
}
else{
ifstop = true;
score = 1000000 - 30000*i - total_times*1500;
document.getElementById('score').innerText = score;
alert('恭喜你,猜对了,您一共猜了:'+i+'次,消耗了:'+total_times+'s\n本次得分:'+score);
}
if(i>=20){alert('对不起,您已经没有机会了,正确答案是'+num);}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货