[緊急]我的外掛plus版怪怪地,
版主: 版主管理群
[緊急]我的外掛plus版怪怪地,
http://phpbb-tw.net/phpbb/viewtopic.php?t=36948
應該是行的,
但是\r
http://www.tytsim.bobos.ca/bbs/index.php
錯誤
但是程式碼應該是對的~
應該是行的,
但是\r
http://www.tytsim.bobos.ca/bbs/index.php
錯誤
但是程式碼應該是對的~
用firefox觀看後的結果
錯誤: syntax error
原始檔: http://www.tytsim.bobos.ca/bbs/index.php
第 238 行,第9 欄
原始碼:
function 24()
錯誤: number is not a function
請勿使用數字當作函數名稱
錯誤: syntax error
原始檔: http://www.tytsim.bobos.ca/bbs/index.php
第 238 行,第9 欄
原始碼:
function 24()
錯誤: number is not a function
請勿使用數字當作函數名稱
但是用\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>
便不可!
<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>
便不可!
其實會出問題的關鍵在於\r
上面的程式碼應該是事後還有做修改的吧? 跟我下午看的好像不太一樣\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的動作
代碼: 選擇全部
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+" 下午"; 以下午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的動作


