Javascriptカウントダウンコード

1809 ワード

JSスクリプト:
 
  
<br>var interval = 1000; <br>function ShowCountDown(year, month, day, divname) { <br>var now = new Date(); <br>var endDate = new Date(year, month - 1, day, 14, 07); <br>var leftTime = endDate.getTime() - now.getTime(); <br>var leftsecond = parseInt(leftTime / 1000); <br>var day1 = Math.floor(leftsecond / (60 * 60 * 24)); <br>var hour1 = Math.floor((leftsecond - day1 * 24 * 60 * 60) / 3600); <br>var hour = Math.floor((leftsecond - 60 * 60) / 3600); <br>// 0 <br>if (hour > 0) { <br>} <br>else { <br>hour = 0; <br>} <br>if (day1 < 0) { <br>hour = hour1 <br>} <br>var minute = Math.floor((leftsecond - day1 * 24 * 60 * 60 - hour1 * 3600) / 60); <br>var second = Math.floor(leftsecond - day1 * 24 * 60 * 60 - hour1 * 3600 - minute * 60); <br>var cc = document.getElementById(divname); <br>// 0 <br>if (leftTime > 0) { <br>cc.innerHTML = hour + " " + minute + " " + second + " "; <br>// <br>//cc.innerHTML = " " + year + " " + month + " " + day + " :" + hour + " " + minute + " " + second + " "; <br>} <br>else { <br>cc.innerHTML = 0 + " " + 0 + " " + 0 + " "; <br>} <br>} <br>//showData DIV ID 2010,8,10 。 <br>window.setInterval(function () { ShowCountDown(2010, 8, 10, 'showData'); }, interval); <br>
表示時間が必要な位置に下記のコードを追加します.