0
我有一個倒計時的頂欄。它在Chrome和Firefox上運行良好,但我意識到它似乎不適用於Safari。 這是代碼:時間倒計時在Chrome中工作,但不是Safari瀏覽器
<div class="deadline_Container">
<div id="clockdiv">
<span class="deadline_Text">You only have </span>
<div><span class="days"></span><span class="smalltext">Days</span></div>
<div><span class="hours"></span><span class="smalltext">Hours</span></div>
<div><span class="minutes"></span><span class="smalltext">Minutes</span>
</div>
<div class="clockLast"><span class="seconds"></span><span class="smalltext">Seconds</span></div>
<span class="deadline_Text2">left to get free delivery!</span></div>
</div>
<script type="text/javascript">
var deadline = 'Jun 15 2016 23:59:59 GMT';
function time_remaining(endtime){
var t = Date.parse(endtime) - Date.parse(new Date());
var seconds = Math.floor((t/1000) % 60);
var minutes = Math.floor((t/1000/60) % 60);
var hours = Math.floor((t/(1000*60*60)) % 24);
var days = Math.floor(t/(1000*60*60*24));
return {'total':t, 'days':days, 'hours':hours, 'minutes':minutes, 'seconds':seconds};
}
function run_clock(id,endtime) {
var clock = document.getElementById(id);
var days_span = clock.querySelector('.days');
var hours_span = clock.querySelector('.hours');
var minutes_span = clock.querySelector('.minutes');
var seconds_span = clock.querySelector('.seconds');
function update_clock(){
var t = time_remaining(endtime);
days_span.innerHTML = t.days;
hours_span.innerHTML = ('0' + t.hours).slice(-2);
minutes_span.innerHTML = ('0' + t.minutes).slice(-2);
seconds_span.innerHTML = ('0' + t.seconds).slice(-2);
if(t.total<=0) {
clearInterval(timeinterval);
}
}
update_clock();
var timeinterval = setInterval(update_clock,1000);
}
run_clock('clockdiv',deadline);
</script>
現在上的天數,小時,分鐘野生動物園insteadt等離開時說:「男」「一」「一個」。所以我認爲這與時間格式有關?
我試過設置的時候是這樣的:
var deadline = '2016-06-15T23:59:59 GMT +0100';
但這並沒有工作。有任何想法嗎?