js+php 카운트다운 실현

1418 단어
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<body>
<div class="bd">
<div class="time"><span class="dn"> xx :</span><br/>
   <span class="h" id="miaosha_hour">0</span><br/>
   <span class="m" id="miaosha_min">0</span><br/>
   <span class="s" id="miaosha_sec">0</span></div><br/>
</div>
</body>
<?php date_default_timezone_set("Asia/ShangHai");// ?>
<script type="text/javascript">
 var runtimes = 0;
  $(document).ready(function (){
       GetRTime();
    });

  // 
  function GetRTime(){
     var nMS = <?php echo 9000;//time  ?>-runtimes*1000;
     if(nMS > 0){
      var nH=Math.floor(nMS/(1000*60*60));
      var nM=Math.floor(nMS/(1000*60)) % 60;
      var nS=Math.floor(nMS/1000) % 60;
      $("#miaosha_hour").html(nH);
      $("#miaosha_min").html(nM);
      $("#miaosha_sec").html(nS);
       runtimes++;
       setTimeout("GetRTime()",1000);
     }
   }
 </script>
</html>

좋은 웹페이지 즐겨찾기