第 1 頁 (共 2 頁)
[緊急]我的外掛plus版怪怪地,
發表於 : 2005-07-24 14:11
由 *tytsim*
發表於 : 2005-07-24 14:15
由 ~倉木麻衣~
用firefox觀看後的結果
錯誤: syntax error
原始檔:
http://www.tytsim.bobos.ca/bbs/index.php
第 238 行,第9 欄
原始碼:
function 24()
錯誤: number is not a function
請勿使用數字當作函數名稱
發表於 : 2005-07-24 14:17
由 *tytsim*
oh!
我知了
等我改改~
發表於 : 2005-07-24 17:55
由 ~倉木麻衣~
時間判斷的語法有大問題哦\r
下午(PM)的時間會被判斷成上午(AM)
另外就是格式不是很統一
例如早上2點會顯示 02:XX:XX AM
而下午2點則是顯示 2:XX:XX PM
發表於 : 2005-07-24 17:57
由 *tytsim*
等我再改改~
發表於 : 2005-07-24 18:05
由 *tytsim*
用\r
代碼: 選擇全部
if (h < 22 & h > 12 ) cl= " 目前時間: 0"+h+":"+m+":"+s+" PM";
恰當嗎??
發表於 : 2005-07-24 18:08
由 chsa
*tytsim* 寫:用\r
代碼: 選擇全部
if (h < 22 and h >12 ) cl= " 目前時間: 0"+h+":"+m+":"+s+" PM";
恰當嗎??
那下午11點的話..不就011:XX:XX了嗎?

是這樣嗎? 哈哈..我也不知道

發表於 : 2005-07-24 18:13
由 *tytsim*
if (h < 22 & h > 12 ) cl= " 目前時間: 0"+h+":"+m+":"+s+" PM";
懂看嗎??
如果
是\r
h < 22
即是09,08,07,06,05,04,03,02,01
h > 12
即是到了24小時制的12之後就加0~
但是12小時制會把13-12
=下午1時,下午1時加一個0= 下午01時
明嗎??
發表於 : 2005-07-24 18:14
由 *tytsim*
還有是加上,
不是換做!!!
發表於 : 2005-07-24 18:22
由 chsa
*tytsim* 寫:if (h < 22 & h > 12 ) cl= " 目前時間: 0"+h+":"+m+":"+s+" PM";
懂看嗎??
如果
是\r
h < 22
即是09,08,07,06,05,04,03,02,01
h > 12
即是到了24小時制的12之後就加0~
但是12小時制會把13-12
=下午1時,下午1時加一個0= 下午01時
明嗎??
懂了..

,謝謝*tytsim*學長..^_^..
發表於 : 2005-07-24 19:01
由 *tytsim*
怪怪,
點解pm和am會對換了??
明明
是\r
h < 12
發表於 : 2005-07-24 19:15
由 *tytsim*
但是用\r
<script language="JavaScript" type="text/javascript">
<!--
timeID = 10;
stcnt = 16;
msg = "{WELCOME_MESSAGE}";
wmsg = new Array(32);
wmsg[0]=msg;
blnk = " ";
for (i=1; i<32; i++)
{
b = blnk.substring(0,i);
wmsg="";
for (j=0; j<msg.length; j++) wmsg=wmsg+msg.charAt(j)+b;
}
function twofour()
{
ct = new Date();
h = "0"+ct.getHours();
m = "0"+ct.getMinutes();
s = "0"+ct.getSeconds();
h = h.substring(h.length-2,h.length+1);
m = m.substring(m.length-2,m.length+1);
s = s.substring(s.length-2,s.length+1);
cl = " 目前時間: "+h+":"+m+":"+s+" ";
if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
if (stcnt-- < -40) stcnt=31;
status = cl+str;
clearTimeout(timeID);
timeID = setTimeout("twofour()",100);
}
function onetwo()
{
ct = new Date();
h = "0"+ct.getHours();
m = "0"+ct.getMinutes();
s = "0"+ct.getSeconds();
h = h.substring(h.length-2,h.length+1);
m = m.substring(m.length-2,m.length+1);
s = s.substring(s.length-2,s.length+1);
if (h > 12)
{
h = h-12 ;
cl = " 目前時間: "+h+":"+m+":"+s+" 下午";
}
if (h <= 12) cl = " 目前時間: "+h+":"+m+":"+s+" 上午";
if (h < 10 & h > 0 ) cl= " 目前時間: 0"+h+":"+m+":"+s+" 下午";
if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
if (stcnt-- < -40) stcnt=31;
status = cl+str;
clearTimeout(timeID);
timeID = setTimeout("onetwo()",100);
}
-->
</script>
便可\r
用\r
<script language="JavaScript" type="text/javascript">
<!--
timeID = 10;
stcnt = 16;
msg = "{WELCOME_MESSAGE}";
wmsg = new Array(32);
wmsg[0]=msg;
blnk = " ";
for (i=1; i<32; i++)
{
b = blnk.substring(0,i);
wmsg="";
for (j=0; j<msg.length; j++) wmsg=wmsg+msg.charAt(j)+b;
}
function twofour()
{
ct = new Date();
h = "0"+ct.getHours();
m = "0"+ct.getMinutes();
s = "0"+ct.getSeconds();
h = h.substring(h.length-2,h.length+1);
m = m.substring(m.length-2,m.length+1);
s = s.substring(s.length-2,s.length+1);
cl = " 目前時間: "+h+":"+m+":"+s+" ";
if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
if (stcnt-- < -40) stcnt=31;
status = cl+str;
clearTimeout(timeID);
timeID = setTimeout("twofour()",100);
}
function onetwo()
{
ct = new Date();
h = "0"+ct.getHours();
m = "0"+ct.getMinutes();
s = "0"+ct.getSeconds();
h = h.substring(h.length-2,h.length+1);
m = m.substring(m.length-2,m.length+1);
s = s.substring(s.length-2,s.length+1);
if (h > 12)
{
h = h-12 ;
cl = " 目前時間: "+h+":"+m+":"+s+" 下午";
}
if (h <= 12) cl = " 目前時間: "+h+":"+m+":"+s+" 上午";
if (h < 22 & h > 12 ) cl= " 目前時間: 0"+h+":"+m+":"+s+" 下午";
if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
if (stcnt-- < -40) stcnt=31;
status = cl+str;
clearTimeout(timeID);
timeID = setTimeout("onetwo()",100);
}
-->
</script>
便不可!
發表於 : 2005-07-24 19:33
由 Kill
雖然是重新整合
但是還是請加上加強作者名稱

發表於 : 2005-07-24 19:35
由 *tytsim*
險些忘了...
發表於 : 2005-07-24 19:53
由 ~倉木麻衣~
其實會出問題的關鍵在於\r
代碼: 選擇全部
if (h > 12)
{
h = h-12 ;
cl = " 目前時間: "+h+":"+m+":"+s+" 下午";
}
if (h <= 12) cl = " 目前時間: "+h+":"+m+":"+s+" 上午";
if (h < 10 & h > 0 ) cl= " 目前時間: 0"+h+":"+m+":"+s+" 下午";
上面的程式碼應該是事後還有做修改的吧? 跟我下午看的好像不太一樣\r
以下午2點為例 , h = 14
一開始會先符合h > 12 的條件而對h做減12的動作
此時的h = 2, 而cl =
" 目前時間: "+h+":"+m+":"+s+" 下午"
接下來又會因為符合 h <=12而使得cl =
" 目前時間: "+h+":"+m+":"+s+" 上午"
最後則又符合 h<10 & h > 0 而使得cl =
" 目前時間: 0"+h+":"+m+":"+s+" 下午"
因此就下午時間的轉換上是ok了(這也是我說好像是事後有做修改過的原因@@)
然而這樣的話, 就變成上午的轉換出問題了
同樣以上午2點為例, 此時的h=02(注意, 是02哦)
首先會符合h <=12而使得cl =
" 目前時: "+h+":"+m+":"+s+" 上午"
但很不幸的, 它也會符合h<10 & h > 0 而使得cl =
" 目前時間: 0"+h+":"+m+":"+s+" 下午"
最後就印出 目前時間:
002:xx:xx
下午
最大的問題在於採用二個獨立的if 來判斷是上午或下午
應該用if..else 或 if...else if 來判斷會比較好\r
另外, 時間補0的問題就再留給你傷腦筋好了
建議別太早做補0的動作
