返回主页网页素材图库gif动画图库网页模板网页教程网页特效网页背景音乐网页制作软件下载网页设计字体下载透明FLASH素材
 


时间日期特效
时钟:小巧却是用得最多的时间显示方法
效果演示:
_CLOCK_

以下是源代码:

<div id=RStimeLayer style="position: absolute; left: 494; top: 101; width: 94; height: 19">_CLOCK_</div>

<script language="JavaScript1.2" >
RStimeFormat = "%h:%m:%s %a";
function RS_getTimeString(format) {
ptr = format.indexOf("%"); old = 0; time="";
while(ptr != -1) {
ch = format.charAt(ptr+1);
time += format.substring(old,ptr) + RS_getFormat(ch);
old = ptr+2;
ptr = format.indexOf("%",old);
}
time += format.substring(old,format.length);
return time;
}
function RS_setDigits(num, howmany) {
str = num.toString();
if (str.length >= howmany) return str;
for (i = str.length; i < howmany; i++) str = "0" + str;
return str;
}
function RS_getFormat(ch) {
now = new Date();
if(ch=='h') {
hour = now.getHours();
if(hour == 0) { hour = 12; }
else if (hour > 12) { hour -= 12; }
return hour; }
else if(ch=='H') { return now.getHours(); }
else if(ch=='m') { return RS_setDigits(now.getMinutes(),2); }
else if(ch=='s') { return RS_setDigits(now.getSeconds(),2); }
else if(ch=='d') { return now.getDate(); }
else if(ch=='D') {
return monArray[now.getMonth()]; }
else if(ch=='y') {
return ((now.getYear() <= 99) ? now.getYear() : RS_setDigits(now.getYear()-2000,2));}
else if(ch=='Y') {
return ((now.getYear() <= 99) ? "19"+now.getYear() : now.getYear());}
else if(ch=='a') {
if(now.getHours() == 0 || now.getHours() > 11) return "PM";
else return "AM"; }
else return "";
} function RS_changeText(id, str) {
if(document.layers) { // if Navigator 4.0+
with(document[id].document) {
open();
write(str);
close();
}
} else { // Internet Explorer 4.0+
document.all[id].innerHTML = str;
}
}

function RS_startClock() {
ClockID = setInterval("RS_changeText('RStimeLayer',RS_getTimeString(RStimeFormat))",500)
}

if(document.all||document.layers) RS_startClock();
</script>

 

 友情连接
 
© CopyRight 2002-2003, www.dabaoku.com, Inc. All Rights Reserved