蛋疼疼到底……把代码发下……第一个javascript……欢迎更蛋疼的人批评指正……

非IE浏览器不会出提示音……

只发代码,.wav没带,明白意思就行

———————————————————————-

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>辩论比赛计时器</title>

<script language=”JavaScript”>
iszheng=1;
function playSound()  
{  
  try{  
   document.all.bgss.src=”remind.wav”;    
   bgss.play();  
   }  
catch(e){  }  
  } 
function time(m,s)
{
this.m=m;
this.s=s;
}
zheng=new time(0,0);
fan=new time(0,0);
function settime(minutes)
{
zheng.m=parseInt(minutes);
zheng.s=(minutes-parseInt(minutes))*60;
fan.m=parseInt(minutes);
fan.s=(minutes-parseInt(minutes))*60;
}
function setsection(s)
{
if(s==1)
   {document.form3.time.value =3;iszheng=1;change();}
if(s==2)
   {document.form3.time.value =2;iszheng=1;change();}
if(s==3)
   {document.form3.time.value =1.5;iszheng=1;change();}
if(s==4)
   {document.form3.time.value =5;iszheng=1;change();}
if(s==5)
   {document.form3.time.value =3;iszheng=0;change();}
   clearTimeout(id);
document.form2.zhengrest.value=””;
document.form2.fanrest.value=””;
document.form2.zhengrest.style.visibility=”visible”;
document.form2.fanrest.style.visibility=”visible”;
}
function re()
{ settime(document.form3.time.value);
document.form2.zhengrest.value =zheng.m+”分”+zheng.s+”秒”;
document.form2.fanrest.value =fan.m+”分”+fan.s+”秒”;
clearTimeout(id);
document.form2.zhengrest.style.visibility=”visible”;
document.form2.fanrest.style.visibility=”visible”;
}
function go1()
{
settime(document.form3.time.value);
document.form2.zhengrest.value =zheng.m+”分”+zheng.s+”秒”;
document.form2.fanrest.value =fan.m+”分”+fan.s+”秒”;
id = setTimeout( “go2()”, 1000);
}
function go2()
{
if(iszheng==1)
   {
    if(zheng.s==0)
       {zheng.m–;
        zheng.s=59;
       }
    else {zheng.s–;
          }
    if(zheng.m==0&&zheng.s==30)
        playSound();
    if(zheng.m==0&&zheng.s<=5&&zheng.s>0)
        playSound();
    if(zheng.m==0&&zheng.s==0)
       {
        alert(“正方时间到!”);
        document.form2.zhengrest.style.visibility=”hidden”;
       }
    }
if(iszheng==0){
     if(fan.s==0)
        {
         fan.m–;
         fan.s=59;
        }
     else {fan.s–;
          }
     if(fan.m==0&&fan.s==30)
        playSound();
      if(fan.m==0&&fan.s<=5&&fan.s>0)
        playSound();
     if(fan.m==0&&fan.s==0)
       {
        alert(“反方时间到!”);
        document.form2.fanrest.style.visibility=”hidden”;
       }
    }
document.form2.zhengrest.value =zheng.m+”分”+zheng.s+”秒”;
document.form2.fanrest.value =fan.m+”分”+fan.s+”秒”;
id = setTimeout( “go2()”, 1000);   
}
function change()
{if(iszheng==1)
   {document.form4.nowtiming.value=”正方”;
   }
if(iszheng==0)
   {document.form4.nowtiming.value=”反方”;
   }
}
</script>

<style type=”text/css”>
body,td,th {
    color: #000;
}
body {
    background-color: #0CF;
}
</style>
</head>

<body>
<bgsound loop=false autostart=false id=”bgss” name=”bgss”>
<form id=”form1″ name=”form1″ method=”post” action=””>
  <p>&nbsp;</p>
  <p align=”center”><font size=14><strong>辩论比赛计时器</strong></font></p>
</form>
<form id=”form2″ name=”form2″ method=”post” action=””>
  <table width=”100%” border=”0″>
    <tr>
      <td width=”19%” height=”60″><font size=6>正方剩余时间</font></td>
      <td width=”31%”><input name=”zhengrest” type=”text” id=”zhengrest” size=”15″ /></td>
      <td width=”19%”><font size=6>反方剩余时间</font></td>
      <td width=”31%”><input name=”fanrest” type=”text” id=”fanrest” size=”15″ /></td>
      <td width=”0%”></label><td width=”0%”></td>
    </tr>
  </table>
</form>
<form id=”form3″ name=”form3″ method=”post” action=””>
  <table width=”50%” border=”0″>
    <tr>
      <td width=”38%” height=”74″><font size=6>每方时间</font></td>
      <td width=”62%”><label>
        <input name=”time” type=”text” id=”time” size=”5″ />
      分钟</label></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
<form id=”form4″ name=”form4″ method=”post” action=””>
  <table width=”1130″>
    <tr>
      <td width=”129″>阶段设置</td>
      <td width=”130″>
      <label>
        <input type=”radio” name=”RadioGroup” value=”s1″ id=”section1″ onClick=”setsection(1);”/>
        立论
      </label></td>
      <td width=”305″>&nbsp;</td>
      <td width=”201″><label>
        <input type=”button” name=”button1″ id=”button1″ value=”开始计时!” onClick=”go1();change();”/>
      </label></td><td width=”341″>
      <label><input type=”button” name=”button2″ id=”button2″ value=”重置” onClick=”re();”/>
      </label></td>
    </tr>
    <tr><td></td>
   &
nbsp;  <td><label>
        <input type=”radio” name=”RadioGroup” value=”s2″ id=”section2″ onClick=”setsection(2);”/>
        攻辩
      </label></td>
      &lt;td></td><td><label>
        <input type=”button” name=”button3″ id=”button3″ value=”交换计时队伍” onclick=”iszheng=iszheng^1;change();” />
      </label></td>
      <td></td>
    </tr>
    <tr><td></td>
      <td><label>
        <input type=”radio” name=”RadioGroup” value=”s3″ id=”section3″ onClick=”setsection(3);”/>
        小结
      </label></td>
      <td></td>
      <td>当前计时队伍:
      <input name=”nowtiming” type=”text” id=”nowtiming”  size=”12″ /></td><td></td>
    </tr>
    <tr><td></td>
      <td><label>
        <input type=”radio” name=”RadioGroup” value=”s4″ id=”section4″ onClick=”setsection(4);”/>
        自由
      </label></td>
      <td></td><td></td><td></td>
    </tr>
    <tr><td></td>
      <td><label>
        <input type=”radio” name=”RadioGroup” value=”s5″ id=”section5″ onClick=”setsection(5);”/>
        总结
      </label></td>
      <td></td><td></td><td></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</form>
<p>&nbsp;</p>
</body>
</html>


已发布

分类

来自

标签:

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注