很久以前就不建議使用getYear()這個函數,因為在火狐中顯示是不正確的,推薦使用getFullYear() 函數。
另外火狐不支援innerText這個屬性,需要改成textContent才能接收。
然後附上程式碼
var s,Sys =var s,Sys =var s,Sys =var s,Sys =var s,Sys =var s,Sys =var s,Sys =var s,Sys =var s,Sys =var s,Sys =var s,Sys = {},ua = window.navigator.userAgent.toLowerCase();
(s = ua.match(/msie ([d.] )/)) ? Sys.ie = s[1] :
( s = ua.match(/firefox/([d.] )/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome/([d.] )/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([d.] )/)) ? Sys.opera = s[1] :
(s = ua. match(/version/([d.] ).*safari/)) ? Sys.safari = s[1] : 0;
//瀏覽器版本號進行測試
//if (Sys.ie ) { document.write('IE: ' Sys.ie); }
//if (Sys.firefox){ document.write('Firefox: ' Sys.firefox);}
//if (Sys .chrome){ document.write('Chrome: ' Sys.chrome);}
//if (Sys.opera){ document.write('Opera: ' Sys.opera);}
//if (Sys.safari) { document.write('Safari: ' Sys.safari); }
var today = new Date();
var day,date;
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 = " 星期六"; }
date = "今天是:" (today.getFullYear()) "年" (today.getMonth() 1) "月" today.getDate() "日" day "";
if (Sys.firefox)
{
document.getElementById('time_id').textContent = date;
} else {
document.getElementById('time_id').innerText = date;
}