简单是简单,但是对于一个没写过javascript的人来说,花时间去学习再写成本太高啊。

解决方案 »

  1.   


    <!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=gb2312" /> 
    <title>无标题文档 </title> 
    <script type="text/JavaScript">  var stingTime;
     var   timeLeft   =   10 ;   
      function   countTime()   
      {   
       document.getElementById("hehe").disabled=true;  if(timeLeft   ==   0)   
      {   
              //alert("时间到!");
      location.href="http://www.baidu.com";
              return;   
      }    
              document.getElementById("timeDiv").innerHTML   =   "剩余时间:"  +  timeLeft   +   "秒";   
              timeLeft   =   timeLeft   -   1;   
              setTimeout('countTime()',1000);   
      }   </script> </head> 
    <body> 
    <input type='button' value='开始考试' onclick='countTime();' id='hehe'>
    <div id='timeDiv'></div>
     </body> </html>
      

  2.   

    呵呵,3楼主要是用的setTimeout('countTime()',1000);   我再提一个方法,在进入的JSP页写个自动跳转呵呵~没有3楼的好,而且倒计时得另外处理