gaoss33 发表于 2008-2-9 22:54

能在论坛显示的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>
&lt;SCRIPT language=JavaScript&gt;<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 = "&lt;font size=5 face=华文新魏 color=cadet&gt;" + (today.getYear())+ "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日" + "&lt;/font&gt;";<BR>   date2 = "&lt;font size=5 face=华文新魏 color=cadet&gt;" +day + "&lt;/font&gt;";<BR>   document.write("&lt;center&gt;" + date1.fontsize(2) + date2.fontsize(2) + "&lt;/center&gt;");<BR>   <BR>&lt;/SCRIPT&gt;

<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>&lt;script LANGUAGE="JavaScript"&gt;</P>
<P>Stamp = new Date();<BR>var Hours;<BR>var Mins;<BR>var Time;<BR>Hours = Stamp.getHours();<BR>if (Hours &gt;= 12) {<BR>Time = " P.M.";<BR>}<BR>else {<BR>Time = " A.M.";<BR>}<BR>if (Hours &gt; 12) {<BR>Hours -= 12;<BR>}<BR>if (Hours == 0) {<BR>Hours = 12;<BR>}<BR>Mins = Stamp.getMinutes();<BR>if (Mins &lt; 10) {<BR>Mins = "0" + Mins;<BR>}    <BR>document.write('&lt;font size="5" face="Arial" color=cadet&gt;' + Hours + ":" + Mins + '&lt;/font&gt;');<BR>document.write('&lt;font size="3" face="Arial" color=cadet&gt;' + Time + '&lt;/font&gt;');</P>
<P>&lt;/script&gt;</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>&lt;script LANGUAGE="JavaScript"&gt;</P>
<P>Stamp = new Date();<BR>var Hours;<BR>var Mins;<BR>var Time;<BR>Hours = Stamp.getHours();<BR>if (Hours &gt;= 24)</P>
<P>if (Hours &gt; 24) {<BR>Hours -= 24;<BR>}<BR>if (Hours == 0) {<BR>Hours = 24;<BR>}<BR>Mins = Stamp.getMinutes();<BR>if (Mins &lt; 10) {<BR>Mins = "0" + Mins;<BR>}    <BR>document.write('&lt;font size="5" face="Arial" color=cadet&gt;' + Hours + ":" + Mins + '&lt;/font&gt;');</P>
<P>&lt;/script&gt;</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>&lt;span id="liveclock" style"=width: 109px; height: 15px"&gt;&lt;/span&gt;<BR>&lt;SCRIPT language=javascript&gt;<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&lt;=9)<BR>minutes="0"+minutes<BR>if(seconds&lt;=9)<BR>seconds="0"+seconds<BR>myclock="&lt;font size='5' color=cadet&gt;"+hours+":"+minutes+":"+seconds+"&lt;/font&gt;"<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>//--&gt;<BR>&lt;/SCRIPT&gt;</P>


<BR><BR>

小白兔 发表于 2008-2-9 23:02

谢谢高老师,来学习了!!

gaoss33 发表于 2008-2-9 23:09

倒计时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>&lt;font color=#00FF00 face=华文新魏 size=4&gt;离08年劳动节还有:&lt;/font&gt;
&lt;span id=\\&quot;span_dt_dt\\&quot; style=\'align=center no:1px solid \'&gt;&lt;/span&gt;
&lt;SCRIPT language=javascript&gt;
&lt;!--
//document.write(\\&quot;\\&quot;);

function show_date_time(){
window.setTimeout(\\&quot;show_date_time()\\&quot;, 1000);
BirthDay=new Date(\\&quot;5-1-2008\\&quot;);//这个日期是可以修改的
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=\\&quot;&lt;b&gt;&lt;align=center&gt;&lt;font color=#00FF00 face=华文新魏 size=4&gt;\\&quot;+daysold+\\&quot;天\\&quot;+hrsold+\\&quot;小时\\&quot;+minsold+\\&quot;分\\&quot;+seconds+\\&quot;秒\\&quot;+\\&quot;&lt;/b&gt;
&lt;/font&gt;\\&quot; ;

}

show_date_time();

//--&gt;
&lt;/SCRIPT&gt;</pre>

[ 本帖最后由 gaoss33 于 2008-2-9 23:43 编辑 ]

快乐相随 发表于 2008-2-9 23:18

谢谢高老师,以后可以用到帖子里了。

快乐相随 发表于 2008-2-9 23:21

<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 编辑 ]

快乐相随 发表于 2008-2-9 23:27

怎么没改对呢?麻烦高老师看看。

gaoss33 发表于 2008-2-9 23:34

呵呵,同样JS在一个页面只能显示一个

快乐相随 发表于 2008-2-9 23:47

原来是这样,我还以为我改错了,这回成功了。

快乐相随 发表于 2008-2-9 23:48

window.setTimeout(\"show_date_time()\", 1000);
BirthDay=new Date(\"5-1-2008\");//这个日期是可以修改的

再问一下高老师,这个时间里的1000是根据时间长短修改的吧。

坐在墙头啃玉米 发表于 2008-2-10 01:25

高老师,你来了啊!
页: [1] 2 3 4
查看完整版本: 能在论坛显示的JS时间代码