能在论坛显示的JS时间代码
<BR><BR><SCRIPT language=JavaScript>
var enabled = 0; today = new Date();
var day; var 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 = "星期六"
document.fgColor = " cadet";
date1 = "<font size=5 face=华文新魏 color=cadet>" + (today.getYear())+ "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日" + "</font>";
date2 = "<font size=5 face=华文新魏 color=cadet>" +day + "</font>";
document.write("<center>" + date1.fontsize(2) + date2.fontsize(2) + "</center>");
</SCRIPT>
<BR><BR>
代码:
<BR><BR>
<SCRIPT language=JavaScript><BR> var enabled = 0; today = new Date();<BR> var day; var date;<BR> if(today.getDay()==0) day = "星期日"<BR> if(today.getDay()==1) day = "星期一"<BR> if(today.getDay()==2) day = "星期二"<BR> if(today.getDay()==3) day = "星期三"<BR> if(today.getDay()==4) day = "星期四"<BR> if(today.getDay()==5) day = "星期五"<BR> if(today.getDay()==6) day = "星期六"<BR> document.fgColor = " cadet";<BR> date1 = "<font size=5 face=华文新魏 color=cadet>" + (today.getYear())+ "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日" + "</font>";<BR> date2 = "<font size=5 face=华文新魏 color=cadet>" +day + "</font>";<BR> document.write("<center>" + date1.fontsize(2) + date2.fontsize(2) + "</center>");<BR> <BR></SCRIPT>
<BR><BR>
还能改变字体及大小,颜色.
<BR><BR><BR><BR>
时间显示:
<BR><BR>
<script LANGUAGE="JavaScript">
Stamp = new Date();
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}
document.write('<font size="5" face="Arial" color=cadet>' + Hours + ":" + Mins + '</font>');
document.write('<font size="3" face="Arial" color=cadet>' + Time + '</font>');
</script>
<BR><BR><BR>代码:<BR><BR>
<P><script LANGUAGE="JavaScript"></P>
<P>Stamp = new Date();<BR>var Hours;<BR>var Mins;<BR>var Time;<BR>Hours = Stamp.getHours();<BR>if (Hours >= 12) {<BR>Time = " P.M.";<BR>}<BR>else {<BR>Time = " A.M.";<BR>}<BR>if (Hours > 12) {<BR>Hours -= 12;<BR>}<BR>if (Hours == 0) {<BR>Hours = 12;<BR>}<BR>Mins = Stamp.getMinutes();<BR>if (Mins < 10) {<BR>Mins = "0" + Mins;<BR>} <BR>document.write('<font size="5" face="Arial" color=cadet>' + Hours + ":" + Mins + '</font>');<BR>document.write('<font size="3" face="Arial" color=cadet>' + Time + '</font>');</P>
<P></script></P>
<BR><BR><BR><BR>
24时制显示:
<BR><BR>
<script LANGUAGE="JavaScript">
Stamp = new Date();
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 24)
if (Hours > 24) {
Hours -= 24;
}
if (Hours == 0) {
Hours = 24;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}
document.write('<font size="5" face="Arial" color=cadet>' + Hours + ":" + Mins + '</font>');
</script>
<BR><BR><BR>代码:<BR><BR>
<P><BR><script LANGUAGE="JavaScript"></P>
<P>Stamp = new Date();<BR>var Hours;<BR>var Mins;<BR>var Time;<BR>Hours = Stamp.getHours();<BR>if (Hours >= 24)</P>
<P>if (Hours > 24) {<BR>Hours -= 24;<BR>}<BR>if (Hours == 0) {<BR>Hours = 24;<BR>}<BR>Mins = Stamp.getMinutes();<BR>if (Mins < 10) {<BR>Mins = "0" + Mins;<BR>} <BR>document.write('<font size="5" face="Arial" color=cadet>' + Hours + ":" + Mins + '</font>');</P>
<P></script></P>
<BR><BR>
<BR><BR><BR><BR>
24时制带秒走动显示:
<BR><BR>
<span id="liveclock" style"=width: 109px; height: 15px"></span>
<SCRIPT language=javascript>
function www_helpor_net()
{
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="<font size='5' color=cadet>"+hours+":"+minutes+":"+seconds+"</font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
//-->
</SCRIPT>
<BR><BR><BR>代码:<BR><BR>
<P><span id="liveclock" style"=width: 109px; height: 15px"></span><BR><SCRIPT language=javascript><BR>function www_helpor_net()<BR>{<BR>var Digital=new Date()<BR>var hours=Digital.getHours()<BR>var minutes=Digital.getMinutes()<BR>var seconds=Digital.getSeconds()</P>
<P>if(minutes<=9)<BR>minutes="0"+minutes<BR>if(seconds<=9)<BR>seconds="0"+seconds<BR>myclock="<font size='5' color=cadet>"+hours+":"+minutes+":"+seconds+"</font>"<BR>if(document.layers){document.layers.liveclock.document.write(myclock)<BR>document.layers.liveclock.document.close()<BR>}else if(document.all)<BR>liveclock.innerHTML=myclock<BR>setTimeout("www_helpor_net()",1000)<BR>}<BR>www_helpor_net();<BR>//--><BR></SCRIPT></P>
<BR><BR> 谢谢高老师,来学习了!!
倒计时JS代码
<font color=#00FF00 face=华文新魏 size=4>离08年劳动节还有:</font><span id=\"span_dt_dt\" style=\'align=center no:1px solid \'></span>
<SCRIPT language=javascript>
<!--
//document.write(\"\");
function show_date_time(){
window.setTimeout(\"show_date_time()\", 1000);
BirthDay=new Date(\"5-1-2008\");//这个日期是可以修改的
today=new Date();
timeold=(BirthDay.getTime()-today.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor((e_hrsold-hrsold)*60);
seconds=Math.floor((e_minsold-minsold)*60);
span_dt_dt.innerHTML=\"<b><align=center><font color=#00FF00 face=华文新魏 size=4>\"+daysold+\"天\"+hrsold+\"小时\"+minsold+\"分\"+seconds+\"秒\"+\"</b><br></font>\" ;
}
show_date_time();
//-->
</SCRIPT>
<pre><font color=#00FF00 face=华文新魏 size=4>离08年劳动节还有:</font>
<span id=\\"span_dt_dt\\" style=\'align=center no:1px solid \'></span>
<SCRIPT language=javascript>
<!--
//document.write(\\"\\");
function show_date_time(){
window.setTimeout(\\"show_date_time()\\", 1000);
BirthDay=new Date(\\"5-1-2008\\");//这个日期是可以修改的
today=new Date();
timeold=(BirthDay.getTime()-today.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor((e_hrsold-hrsold)*60);
seconds=Math.floor((e_minsold-minsold)*60);
span_dt_dt.innerHTML=\\"<b><align=center><font color=#00FF00 face=华文新魏 size=4>\\"+daysold+\\"天\\"+hrsold+\\"小时\\"+minsold+\\"分\\"+seconds+\\"秒\\"+\\"</b>
</font>\\" ;
}
show_date_time();
//-->
</SCRIPT></pre>
[ 本帖最后由 gaoss33 于 2008-2-9 23:43 编辑 ] 谢谢高老师,以后可以用到帖子里了。 <font color=#00FF00 face=华文新魏 size=4>离08年国庆节还有:</font>
<span id=\"span_dt_dt\" style=\'align=center no:1px solid \'></span>
<SCRIPT language=javascript>
<!--
//document.write(\"\");
function show_date_time(){
window.setTimeout(\"show_date_time()\", 2000);
BirthDay=new Date(\"10-1-2008\");//这个日期是可以修改的
today=new Date();
timeold=(BirthDay.getTime()-today.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor((e_hrsold-hrsold)*60);
seconds=Math.floor((e_minsold-minsold)*60);
span_dt_dt.innerHTML=\"<b><align=center><font color=#00FF00 face=华文新魏 size=4>\"+daysold+\"天\"+hrsold+\"小时\"+minsold+\"分\"+seconds+\"秒\"+\"</b><br></font>\" ;
}
show_date_time();
//-->
</SCRIPT>
[ 本帖最后由 快乐相随 于 2008-2-9 23:25 编辑 ] 怎么没改对呢?麻烦高老师看看。 呵呵,同样JS在一个页面只能显示一个 原来是这样,我还以为我改错了,这回成功了。 window.setTimeout(\"show_date_time()\", 1000);
BirthDay=new Date(\"5-1-2008\");//这个日期是可以修改的
再问一下高老师,这个时间里的1000是根据时间长短修改的吧。 高老师,你来了啊!