javascript时间显示代码收集

z  查看文章   
javascript时间显示代码收集32007年05月04日 星期五 16:44温度计式样的时间

<title>   温度计式样的时间   </title>
<SCRIPT   language=javascript>
var   cellwidth=10;                                   //   EACH   "CELL"   WIDTH   IN   PIXELS
var   cellheight=10;                                     //   EACH   "CELL"   HEIGHT   IN   PIXELS
var   fontsize=11;                                     //   FONT   SIZE   OF   THE   NUMBERS.   SETTING   THIS   TOO   BIG   CAUSES   UNDESIRED   EFFECTS.
var   fontcolor="080080";                         //   ENTER   ANY   HTML   OR   RGB   COLOR   CODE
var   fontstyle="bold";                         //   ENTER   EITHER   BOLD,   ITALICS,   NONE
var   oncolor="red";                                 //   COLOR   OF   ACTIVE   CELLS
var   offcolor="lightgrey";             //   COLOR   OF   INACTIVE   CELLS
var   NS4   =   (navigator.appName.indexOf("Netscape")>=0   &&   parseFloat(navigator.appVersion)   >=   4   &&   parseFloat(navigator.appVersion)   <   5)?   true   :   false;
var   IE4   =   (document.all)?   true   :   false;
var   NS6   =   (parseFloat(navigator.appVersion)   >=   5   &&   navigator.appName.indexOf("Netscape")>=0   )?   true:   false;
var   binclk,   now;
var   t='<table   cellspacing="1"   cellpadding="0"   border="0"><tr><td   align="center">   </td>';
for(i=0;i<=58;i+=2)t+='<td   align="left"   colspan="2"><font   style="font-size:'+fontsize+'px;   font-weight:'+fontstyle+';   color:   '+fontcolor+'">'+i+'<br>   |</font></td>';
t+='<td>   </td></tr><tr><td   align="center"><font   style="font-size:'+fontsize+'px;   font-weight:'+fontstyle+';   color:   '+fontcolor+'">时:   </font></td>';
for(i=0;i<=23;i++){
t+='<td>';
t+=(NS4)?   '<ilayer   name="hrs'+i+'"   height="'+cellheight+'"   width="'+cellwidth+'"   bgcolor="'+offcolor+'"></ilayer>'   :   '<div   id="hrs'+i+'"   style="position:relative;   width:'+cellwidth+'px;   font-size:1px;   height:'+cellheight+'px;   background-color:'+offcolor+'"></div>';
t+='</td>';
}
t+='<td   colspan="36"><td>   </td></tr><tr><td   align="center"><font   style="font-size:'+fontsize+'px;   font-weight:'+fontstyle+';   color:   '+fontcolor+'">分:   </font></td>';
for(i=0;i<=59;i++){
t+='<td>';
t+=(NS4)?   '<ilayer   name="min'+i+'"   width="'+cellwidth+'"   height="'+cellheight+'"   bgcolor="'+offcolor+'"></ilayer>'   :   '<div   id="min'+i+'"   style="position:relative;   width:'+cellwidth+'px;   font-size:1px;   height:'+cellheight+'px;   background-color:'+offcolor+'"></div>';
t+='</td>';
}
t+='<td>   </td></tr><tr><td   align="center"><font   style="font-size:'+fontsize+'px;   font-weight:'+fontstyle+';   color:   '+fontcolor+'">秒:   </font></td>';
for(i=0;i<=59;i++)
{
t+='<td>';
t+=(NS4)?   '<ilayer   name="sec'+i+'"   width="'+cellwidth+'"   height="'+cellheight+'"   bgcolor="'+offcolor+'"></ilayer>'   :   '<div   id="sec'+i+'"   style="position:relative;   width:'+cellwidth+'px;   font-size:1px;   height:'+cellheight+'px;   background-color:'+offcolor+'"></div>';
t+='</td>';
}
t+='<td>   </td></tr><tr><td>   </td><td>   </td>';
for(i=1;i<=59;i+=2)t+='<td   align="left"   colspan="2"><font   style="font-size:'+fontsize+'px;   font-weight:'+fontstyle+';   color:   '+fontcolor+'">   |<br>'+i+'</font></td>';
t+='</tr></table>';
document.write(t);
function   init(){
getvals();
for(i=0;i<=now.h;i++)setbgcolor('hrs'+i,   oncolor);
for(i=0;i<=now.m;i++)setbgcolor('min'+i,   oncolor);
for(i=0;i<=now.s;i++)setbgcolor('sec'+i,   oncolor);
setInterval('setclock()',   100);
}
function   getvals(){
now=new   Date();
now.s=now.getSeconds();
now.h=now.getHours();
now.m=now.getMinutes();
}
function   setclock(){
getvals();
if((now.h==0)&&(now.m==0))   for(i=1;i<=23;i++)setbgcolor('hrs'+i,   offcolor);
if((now.s==0)&&(now.m==0))   for   (i=1;i<=59;i++)setbgcolor('min'+i,   offcolor);
if(now.s==0)   for(i=1;i<=59;i++)setbgcolor('sec'+i,   offcolor);
setbgcolor('hrs'+now.h,   oncolor);
setbgcolor('min'+now.m,   oncolor);
setbgcolor('sec'+now.s,   oncolor);
}
function   resize(){
if(NS4)history.go(0);
}
function   setbgcolor(idstr,   color){
if(IE4)document.all[idstr].style.backgroundColor=color;
if(NS4)document.layers[idstr].bgColor=color;
if(NS6)document.getElementById(idstr).style.backgroundColor=color;
}
window.οnlοad=init;
window.οnresize=resize;
</SCRIPT>记录几天后的日期<script language="JavaScript">
<!-- Begin
function AddDays(form) {
DaysToAdd=document.form.DaysToAdd.value;var now=new Date();
var newdate=new Date();
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
document.form.display.value=newdate.toLocaleString();
}
// End -->
</script>
                     <form name=form>
                       <input type=text name=DaysToAdd size=4 value=10 onFocus="this.select()" onMouseOver="this.focus()">
                       <input type=button value="天后的日期将是.." onClick="AddDays(this.form)" name="button">
                       <input type=text name="display" size=20 value="">
                     </form>带开关的时钟<script language="JavaScript">
     var enabled=0;   
function TOfunc() {      
     TO = window.setTimeout( "TOfunc()", 1000
);      
     var today = new Date();  
     document.clock.disp.value =
today.toLocaleString();
     }
</script>
                   <form name="clock">
                     <input type="text" name="disp" value="" size=20
onFocus="this.blur()" >
                     <br>
                     <input type="radio" name="rad" value="off" 
onClick="
   if( enabled==1 )
     {
      document.clock.disp.value='';
      clearTimeout( TO );
      enabled = 0;
      }
    " checked>
                     关<font color="#FFFF99"> </font>
                     <input type="radio" name="rad" value="on" 
onClick="
      if( enabled == 0 ) {
         var TO = setTimeout( 'TOfunc()', 1000 );
         enabled = 1;      }" >
                     开<font color="#FFFF99"> </font>
                   </form>随时间变化提示<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 = " FF0072";
    date1 = "<font size=2 color=red>" + (today.getYear())   + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日   " + "</font>";
    date2 = "<font size=1 color=red>" +   day + "</font>";
    document.write("<center>" + date1.fontsize(3) + date2.fontsize(3) + "</center>");
  
//----->
</SCRIPT>
<SCRIPT language="JavaScript"><!--
document.write("<center><font color=#0066ff size=+1> ")
day = new Date()
hr = day.getHours()
if (hr ==1)
document.write("凌晨一点已过,别忘了休息喔!")
if (hr ==2)
document.write("该休息了,身体可是革命的本钱啊!")
if (hr ==3)
document.write("夜深人静,只有你敲击鼠标的声音...")
if (hr ==4)
document.write("四点过了,你明天不上班???")
if (hr ==5)
document.write("该去晨运了!!!")
if (hr ==6)
document.write("你知道吗,此时是国内网络速度最快的时候!")
if (hr ==7)
document.write("新的一天又开始了,祝你过得快乐!")
if ((hr ==8) || (hr == 9) || (hr ==10))
document.write("上午好!今天你看上去好精神哦!")
if (hr ==11)
document.write("十一点过了,快下班了吧?")
if (hr ==12)
document.write("十二点过了,还不下班?")
if ((hr==13) || (hr==14))
document.write("你不睡午觉?")
if ((hr==15) || (hr==16) || (hr==17))
document.write("下午好!")
if ((hr==18) || (hr==19))
document.write("吃晚饭了吧?")
if ((hr==20) || (hr==21) || (hr==22))
document.write("今晚又在这玩电脑了,没节目?")
if (hr==23)
document.write("真是越玩越精神,不打算睡了?")
if (hr==0)
document.write("凌晨了,还不睡?")
document.write("</font></center>")
//---></SCRIPT>按钮控制时间日期显示<script Language="JavaScript">
<!-- Helpers for JSI page...// Navigation - Startfunction goback(){alert("Good Bye!");history.go(-1);}function getname(str) {         alert("Hi, "+ str+"!");}function gettheDate() {stopclock();Todays = new Date();TheDate = "" + (Todays.getMonth()+ 1) +" / "+ Todays.getDate() + " / " + Todays.getYear() document.clock.face.value = TheDate;}function showit () {         var now = new Date();         var hours = now.getHours();         var minutes = now.getMinutes();         var seconds = now.getSeconds();           stopclock();           TotalTime = (minutes > GetTotal)? (minutes-GetTotal):TotalTime;         document.clock.face.value = TotalTime + " in minutes ";}// Navigation - Stop// Netscapes Clock - Start// this code was taken from Netscapes JavaScript documentation at// www.netscape.com on Jan.25.96var timerID = null;var TotalTime = 0;var GetTotal = 0;var timerRunning = false;function stopclock (){         if(timerRunning)                 clearTimeout(timerID);         timerRunning = false;}function startclock () {         // Make sure the clock is stopped         var now = new Date();         stopclock();           GetTotal=now.getMinutes();         gettheDate()         showtime();}function showtime () {         var now = new Date();         var hours = now.getHours();         var minutes = now.getMinutes();         var seconds = now.getSeconds()         var timeValue = "" + ((hours >12) ? hours -12 :hours)         timeValue += ((minutes < 10) ? ":0" : ":") + minutes         timeValue += ((seconds < 10) ? ":0" : ":") + seconds         timeValue += (hours >= 12) ? " P.M." : " A.M."         document.clock.face.value = timeValue;         timerID = setTimeout("showtime()",1000);         timerRunning = true;}function showtimer () {         var now = new Date();         var hours = now.getHours();         var minutes = now.getMinutes();         var seconds = now.getSeconds()         var timeValue = "" + ((hours >12) ? hours -12 :hours)         timeValue += ((minutes < 10) ? ":0" : ":") + minutes         timeValue += ((seconds < 10) ? ":0" : ":") + seconds         timeValue += (hours >= 12) ? " P.M." : " A.M."           document.clock.Tspent.value = timeValue;         timerID = setTimeout("showtime()",1000);         timerRunning = true;}// Netscapes Clock - Stop// end Helpers -->
</script></head><body bgcolor="#fef4d9" onLoad="startclock()"><form name="clock" onSubmit="0">
        <input      type=button value="Time" size=12 onClick="showtime()">
         <input     type=button value="Date" size=12 onClick="gettheDate()">
         <input type="text" name="face" size=12 value="" StartTimer()>
</form>显示离开某事件多少时间的提示牌<SCRIPT language=javascript><!--BirthDay=new Date("january 01,2001");//改成你的计时日期today=new Date();timeold=(today.getTime()-BirthDay.getTime());sectimeold=timeold/1000secondsold=Math.floor(sectimeold);msPerDay=24*60*60*1000e_daysold=timeold/msPerDaydaysold=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);//--></SCRIPT><SCRIPT language=javascript><!--document.write("新世纪已经进去了"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒了!");//--></SCRIPT>猜你的属相<html>
<head>
<title>猜你的属相</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body    bgcolor=#FFFFFF   >
<!-------------------------------->
<SCRIPT language=JavaScript>
<!--
function getpet () {

         var toyear = 1997;
         var birthyear = document.frm.inyear.value;
         var birthpet="Ox"

         x = (toyear - birthyear) % 12
         if ((x == 1) || (x == -11)) {
             birthpet="您属老鼠"       }
             else   {
              if (x == 0)              {
              birthpet="您属牛"            }
              else   {
               if ((x == 11) || (x == -1)) {
               birthpet="您属老虎"           }
               else   {
                if ((x == 10) || (x == -2)) {
                birthpet="您属兔子"          }
                else   {
                 if ((x == 9) || (x == -3))   {
                 birthpet="您属龙"          }
                 else   {
                  if ((x == 8) || (x == -4))   { 
                  birthpet="您属蛇"       }
                  else   {
                   if ((x == 7) || (x == -5))   { 
                   birthpet="您属马"       }
                   else   {
                    if ((x == 6) || (x == -6))   { 
                    birthpet="您属羊"       }
                    else   {
                     if ((x == 5) || (x == -7))   {  
                     birthpet="您属猴"      }
                     else   {
                      if ((x == 4) || (x == -8))   {
                      birthpet="您属鸡"     }
                      else   {
                       if ((x == 3) || (x == -9))   {
                       birthpet="您属狗"         }
                       else   {
                        if ((x == 2) || (x == -10))   {
                        birthpet="您属猪"          }  
                       }
                      }
                     }
                    }
                   }
                  }
                 }
                }
               }
              }
             }
         document.frm.birth.value = birthpet;

}
// -->
</SCRIPT>
<FORM name=frm>
出生年份:<INPUT name=inyear size=4 value=1975> <BR><INPUT οnclick=getpet() type=button value=看看属什么><INPUT name=birth size=9></FORM><!---------------------------------->
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值