Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Fancy jQuery Clock (IE Fail) Re: Fancy jQuery Clock (IE Fail)

#68000
holly
Member

the best Jaca-Clock I’ve seen. With the following code it’s in function on every browser with jquery-support. But don’t start the page locally with Internet Explorer. If you start the code from a network attached drive or a http-server all works fine.

Code:
// buggy on IE only from start from local drive
function checktime(prevhour,prevmins,prevsecs){
var now = new Date();
var hour = now.getHours();
var mins = now.getMinutes();
var secs = now.getSeconds();
hour=((hour < 10) ? "0" : "") + hour + ""; mins=((mins < 10) ? "0" : "") + mins + ""; secs=((secs < 10) ? "0" : "") + secs + ""; if(prevhour != hour) { prevhour += ""; if(prevhour.charAt(0) != hour.charAt(0)) numberflip('#hourl',hour.charAt(0)); if(prevhour.charAt(1) != hour.charAt(1)) numberflip('#hourr',hour.charAt(1)); } if(prevmins != mins) { prevmins += ""; if(prevmins.charAt(0) != mins.charAt(0)) numberflip('#minl',mins.charAt(0)); if(prevmins.charAt(1) != mins.charAt(1)) numberflip('#minr',mins.charAt(1)); } if(prevsecs != secs) { prevsecs += ""; if(prevsecs.charAt(0) != secs.charAt(0)) numberflip('#secl',secs.charAt(0)); if(prevsecs.charAt(1) != secs.charAt(1)) numberflip('#secr',secs.charAt(1)); } function numberflip(which,number){ if(number != 0) $(which).animate({marginTop: '-'+parseInt((number*140),10)+'px'}, 250, 'linear'); if(number == 0) { var getmargin = parseInt(($(which).css('margin-top')), 10); $(which).animate({marginTop: parseInt((getmargin-140),10)+'px'}, 250, 'linear', function(){ $(this).css("margin-top","0px") }); } } setTimeout(function(){checktime(hour,mins,secs);}, 200); } checktime(00,00,00); if ($.browser.msie) { $('#wrap').animate({opacity: 0.6}, 1000); } else { $('#wrap').animate({opacity: 0.9}, 1000); }

Regards