网上游有很多的调用当前时间的脚本,不过很多不兼容FireFox,一般都是由于千年虫问题引起的,比如2009年会显示109年。下面是一些能兼容FireFox的当前时间的JS脚本。

网上有很多的调用当前时间的脚本,不过绝大多数都不完美——不兼容FireFox,一般都是由于千年虫问题引起的,比如2009年会显示109年。

下面是一些能兼容FireFox的当前时间的JS脚本。

第一种方法:

head metatext/html;utf-8Content-Type / title 兼容FireFox的当前时间的JS脚本 /title /head body DIVtime 当前时间 SCRIPT document.getElementById('time').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());setInterval( document.getElementById('time').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay()); ,1000); /SCRIPT /DIV /body /html

第二种方法:

head metatext/html;utf-8Content-Type / title 兼容FireFox的当前时间的JS脚本 /title scripttext/javascript function startTime()varnew Date()vartoday.getFullYear();vartoday.getMonth();vartoday.getDate()vartoday.getHours()vartoday.getMinutes()vartoday.getSeconds()// add a zero in front of numbersmonths+1months=checkTime(months)d=checkTime(d)m=checkTime(m)s=checkTime(s)varnew Array(7)weekday[0]= 星期日 weekday[1]= 星期一 weekday[2]= 星期二 weekday[3]= 星期三 weekday[4]= 星期四 weekday[5]= 星期五 weekday[6]= 星期六 varweekday[today.getDay()]document.getElementById('ShowTime').innerHTML=years+ 年 +months+ 月 +d+ 日 +w+ +h+ : +m+ : +s;t=setTimeout('startTime()',500)function checkTime(i)if (i 10){i= 0 + i}return I /script /head body bodystartTime() divShowTime /div /body /html