推 s25g5d4:這種寫JS的風格過時了...\ 10/24 21:39
→ oj113068:對不起Orz 我也是圖書館找書+上網找範例的 10/24 22:05
→ oj113068:嗚,我改用innerHTML試試看 Q Q 10/24 22:41
→ kaichan:之後再來用 jquery 吧 :) 10/25 01:48
推 B9: document.write 把程式碼內容取代掉了 10/25 21:08
→ B9: 把 document.write 換成其他東西試試看 10/25 21:08
→ oj113068:我取消掉 document.write整行以後,確實他就不出錯了Orz 10/26 12:53
→ oj113068:感覺好疑惑,因為看書或是找網路範例 很多都用這種作法 10/26 12:54
整個回一下好了
現在改用inner
~略
var now,year,month,day,dayw,hours,minutes,seconds,timeValue;
function showtime(){
now = new Date();
year = now.getFullYear();
month = now.getMonth();
day = now.getDay();
dayw=now.getDate();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
if (dayw<10){
dayw = "0"+dayw;}
if (seconds<10){
seconds="0"+seconds;}
var dayarray=new Array("SUN","MON","TUE","WED","THU","FRI","STA")
var montharray=new Array("1","2","3","4","5","6","7","8","9","10",
"11","12");
timeValue = "<div class='times'>"+"
<div class='day'>"+
year+"/"+montharray[month]+
"/"+dayw+"
</div>"+
"<div='hor'>"+hours+
":"+minutes+":"+seconds+
"<span class='week'>"+
dayarray[day]+"
</span>"+
"</div>"+"
</div>"
daynew.innerHTML = timeValue;
// 火狐要用document.getElementById( "daynew").innerHTML = timeValue;
setTimeout("showtime()",1000);
}
showtime();
~略
<body>
<span id="daynew"></span>
</body>
目前是這樣
然後IE不能用
<p id="daynew"></p>
或<div id="daynew"></div>
我還不懂為什麼 翻書中Orz
※ 編輯: oj113068 來自: 60.249.39.28 (10/26 12:57)
※ 編輯: oj113068 來自: 60.249.39.28 (10/26 13:03)