私のページにこのカウントダウン タイマーがあります: http://www.dirtycookie.co。
ページを更新しないとカウントダウンしません。
参照用に、@ m.dirtycookie.coで同じスクリプトの動作が少し異なります。
index.phpにこのスクリプトがあります<head>
<script>
$(document).ready(function () {
function countdown() {
// input new date here
var newdate = new Date("Mar 01, 2013 20:00:00");
// input new date here
//DO NOT TOUCH THE REST UNLESS YOU KNOW JQUERY WELL
var now = new Date();
var timeDifference = newdate.getTime() - now.getTime();
var d = Math.floor(timeDifference / 1000);
var l = Math.floor(d / 60);
var b = Math.floor(l / 60);
var u = Math.floor(b / 24);
b %= 24; l %= 60; d %= 60;
if(d < 0){ var d = 0}
if(l < 0){ var l = 0}
if(b < 0){ var b = 0}
if(u < 0){ var u = 0}
$(".days").html(u);
$(".hours").html(b);
$(".minutes").html(l);
$(".seconds").html(d);
var timer = setTimeout('countdown()',1000);
//DO NOT TOUCH THE REST UNLESS YOU KNOW JQUERY WELL
}
window.onload=countdown ;
});
</script>
The firebug error: ReferenceError: countdown is not defined
http://www.dirtycookie.co/
Line 106 Line 106 は実際には:var timer = setTimeout('countdown()',1000);
このための HTML は次のとおりです。
<div class="counter_wrap">
<!-- Counter Title -->
<h1>Countdown to Grand-Opening!</h1>
<!-- Counter Title -->
<!-- Counter Section -->
<div class="numbers"><p class="days">23</p><p class="smallfont">Days</p></div>
<div class="numbers"><p class="hours">19</p><p class="smallfont">Hours</p></div>
<div class="numbers"><p class="minutes">7</p><p class="smallfont">Minutes</p></div>
<div class="numbers"><p class="seconds">23</p><p class="smallfont">Seconds</p>
</div>