兼容chrome的走秒时间js特效

function startTime()
{
var today=new Date()
var y=today.getFullYear()
var Mon=today.getMonth() + 1
var d=today.getDate()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()

var day
if(today.getDay()==0)     day = "星期天"
if(today.getDay()==1)     day = "星期一"
if(today.getDay()==2)     day = "星期二"
if(today.getDay()==3)     day = "星期三"
if(today.getDay()==4)     day = "星期四"
if(today.getDay()==5)     day = "星期五"
if(today.getDay()==6)     day = "星期六"


// add a zero in front of numbers<10
Mon=checkTime(Mon)
d=checkTime(d)
h=checkTime(h)
m=checkTime(m)
s=checkTime(s)
document.getElementById('txtTime').innerHTML=y+"-"+Mon+"-"+d+"  "+h+":"+m+":"+s+" "+day
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}

function funClock() {
var now           = new Date();
var iDate         = now.getDate();
var iMonth        = now.getMonth() + 1 ;
var iYear         = now.getYear();
var iHour     = now.getHours();
var iMinute   = now.getMinutes();
var iSecond   = now.getSeconds();
var sHour     = "";
var sMinute   = "";
var sSecond   = "";

  iSecond  = iSecond + 1;
  //alert(sSecond);
  if (iSecond == 60){
    iSecond = 0;
    iMinute = iMinute +1;
    if(iMinute == 60){
      iMinute = 0;
      iHour = iHour +1;
      if(iHour == 24){
        iHour = 0;
      }
    }
  }
  sHour    = iHour;
  sMinute  = iMinute;
  sSecond  = iSecond;
  if (sHour < 10){
    sHour = "0" + sHour;
  }
  if (sMinute < 10 ){
    sMinute = "0" + sMinute;
  }
  if (sSecond < 10){
    sSecond = "0" + sSecond;
  }
  movingtime =iYear + "-" + iMonth + "-" + iDate + " " + sHour + ":" + sMinute + ":" + sSecond;
  if (document.layers) {
    document.layers.clock.document.write(movingtime);
    //document.layers.clock.document.close();
  }
  else if (document.all) {
    clock.innerHTML = movingtime;
  }
  setTimeout("funClock()", 1000);
}


本文固定链接:成事博客兼容chrome的走秒时间js特效
喜欢 (0)分享 (0)
发表我的评论
取消评论

表情     9 + 7 = ? (必填)

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址