dışındaki herhangi bir tarayıcıda çalışmıyor Safari'de herhangi bir hata görünmüyor ve Chrome'da mükemmel şekilde çalışıyor, numaralar Safari'de görünmüyor. Ayrıca, Safari ve Chrome'un mobil sürümünü de kontrol ettim. Gerçekten neyin yanlış olduğunu anlayamıyorum, belki yanlış bir şey biçimlendirdim ve Chrome bunu otomatik olarak telafi ediyor.Neden bu geri sayım javascript chrome
Kodun kendisi oldukça basittir, yalnızca iki zaman ayırmak ve bunları gün, saat, dakika ve saniye sayısını tutan bir nesneye dönüştürmek için basit bir işlevdir. Daha sonra diğer işlev sadece 1 saniyelik aralıklarla çağrılır ve verileri doğru elemanlara yerleştirir.
İşte canlı sitesi https://zeiworld.net/countdown.php
Yoksa size ateş konsolunda bu koyduğunuzda o NaN
yeni TimeTill ile geliyor fark https://jsfiddle.net/4b9py0sg/1/
$(function(){
function TimeTill(startDate, targetDate, floor){
//Set the starting information
var now = startDate;
var tar = Date.parse(targetDate);
var til = tar - now;
//Split the basic millieseconds between each date into days with a decimal
var days = til/1000/60/60/24;
//Take the decimal from days and multiply it by the hours in a day
var hours = (days % 1) * 24;
//Take the decimal from hours and multiply it by the minutes in an hour
var minutes = (hours % 1) * 60;
//Take the decimal from minutes and multiply it by the seconds in a minute
var seconds = (minutes % 1) * 60;
//Store each value in its respective property, flooring it if required
if (floor == true){
this.days = Math.floor(days);
this.hours = Math.floor(hours);
this.minutes = Math.floor(minutes);
this.seconds = Math.floor(seconds);
}else{
this.days = days;
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
}
}
function updateScreen(){
//Store the time between two dates in an object
launchIn = new TimeTill(Date.now(), '2016-04-15 20:00:00 CDT', true);
//Output the time parts to their respective divs
$('.days').html(launchIn.days);
$('.hours').html(launchIn.hours);
$('.minutes').html(launchIn.minutes);
$('.seconds').html(launchIn.seconds);
}
//Start and continue Loop
updateScreen();
setInterval(updateScreen, 1000);
});
Firefox kurarım ve bir göz atacağım – Zei