MozTW 討論區 https://forum.moztw.org/ |
|
为何这段代码在FF中说clock这个ID没找到? https://forum.moztw.org/viewtopic.php?f=13&t=14288 |
第 1 頁 (共 1 頁) |
發表人: | genmous [ 2006-05-29, 17:09 ] |
文章主題 : | 为何这段代码在FF中说clock这个ID没找到? |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> New Document </title> <script type="text/javascript"> function sunkeyclock(){ var Digital = new Date(); var hours = Digital.getHours(); var minutes = Digital.getMinutes(); var seconds = Digital.getSeconds(); if (minutes <= 9) {minutes = "0" + minutes;} if (seconds <= 9) {seconds = "0" + seconds;} myclock = hours + ":" + minutes + ":" + seconds; clock.innerHTML = myclock; setTimeout("sunkeyclock()",1000) } </script> </head> <body onLoad="sunkeyclock()"> <span id="clock"></span> </body> </html> [/code] |
發表人: | kourge [ 2006-05-30, 09:17 ] |
文章主題 : | |
在 var seconds = Digital.getSeconds(); 後面加上這一行... var clock = document.getElementById("clock"); |
發表人: | 訪客 [ 2006-05-30, 12:24 ] |
文章主題 : | |
谢谢楼上的!!!! |
發表人: | 風痕影 [ 2006-05-31, 11:12 ] |
文章主題 : | |
順帶一提,document.getElementById()是標準的寫法 而原本直接取用clock的方法是不標準的喔 ~~~ |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |