很齊全的HTML時間代碼_第1頁
很齊全的HTML時間代碼_第2頁
很齊全的HTML時間代碼_第3頁
很齊全的HTML時間代碼_第4頁
很齊全的HTML時間代碼_第5頁
已閱讀5頁,還剩16頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、<script>functionshow()vardate=newDate();/日期對象varnow=""now=date.getFullYear()+"年"讀英文就行了now=now+(date.getMonth()+1)+"月"取月的時候取的是當前月-1如果想取當前月+1就可以了now=now+date.getDate()+"日"now=now+date.getHours()+"時";now=now+date.getMinutes()+"分";now=now

2、+date.getSeconds()+"秒";document.getElementById("nowDiv").innerHTML=now;/div的html是now這個字符串setTimeout("show()",1000);/設置過1000毫秒就是1秒,調(diào)用show方法)</script><bodyonload="show()"><!-網(wǎng)頁加載時調(diào)用一次以后就自動調(diào)用了-><divid="nowDiv"></div></bo

3、dy>實時走動的數(shù)字時鐘如:下午14:15:00第一步:在<body></body>區(qū)域加入以下代碼XML/HTMIK碼<script>functiontick()varhours,minutes,seconds,xfile;varintHours,intMinutes,intSeconds;vartoday;today=newDate();intHours=today.getHours();intMinutes=today.getMinutes();intSeconds=today.getSeconds();if(intHours=0)hours=&

4、quot;12:"xfile="午夜"elseif(intHours<12)hours=intHours+":"xfile="上午"elseif(intHours=12)hours="12:"xfile="正午"elseintHoursintHours=intHours-12hours=intHours+":"xfile="下午";if(intMinutes<10)minutes="0"+intMinutes+&q

5、uot;:"elseminutes=intMinutes+":"if(intSeconds<10)seconds="0"+intSeconds+""elseseconds=intSeconds+""timeString=xfile+hours+minutes+seconds;Clock.innerHTML=timeString;window.setTimeout("tick();",100);window.onload=tick;</script>復制代碼第二步.將下

6、面的代碼加入html文件任意需要的地方1. <divid="Clock"align="center"style="font-size:20;color:#000000"></div>復制代碼你可以自行更改樣式!二、顯示年月日格式的時間代碼如:2008年11月27日星期四XML/HTMIK碼1.scriptlanguage=javascript>2. today=newDate();3. functioninitArray()4. this.length=initArray.arguments.length

7、5. for(vari=0;i<this.length;i+)6. thisi+1=initArray.argumentsi7. vard=newinitArray(8. “星期日",9. “星期一",10. "星期二",11. "星期三",12. "星期四",13. "星期五",14. "星期六)15. document.write(宋體,>",下午2:17:3616. "<fontcolor=#000000style='font-siz

8、e:9pt;font-family:17. today.getYear(),"年",18. today.getMonth()+1,"月",19. today.getDate(),"日",20. dtoday.getDay()+1,21. "</font>");22. </script>復制代碼三、顯示日期,星期,時間格式的代碼如:2008年11月27日星期四XML/HTMIK碼1.2.3. <SCRIPTlanguage=JavaScript>4. today=newDate()

9、;5. functioninitArray()6. this.length=initArray.arguments.length7. for(vari=0;i<this.length;i+)8. thisi+1=initArray.argumentsi9. vard=newinitArray(10. "星期日",11. "星期一",12. "星期二",13. "星期三",14. "星期四",15. "星期五",16. "星期六");17. docum

10、ent.write(宋體'>",18. "<fontcolor=#ecc1c1style='font-size:9pt;font-family:19. today.getYear(),"年",20. today.getMonth()+1,"月",21. today.getDate(),"日",22. dtoday.getDay()+1,23. ”</font>");24. </SCRIPT>25. </TD>26. <TDclass=b

11、aialign=leftwidth=95>27. <SCRIPTlanguage=JavaScript>28.29. functiontick()30. varhours,minutes,seconds,xfile;31. varintHours,intMinutes,intSeconds;32. vartoday;33. today=newDate();34. intHours=today.getHours();35. intMinutes=today.getMinutes();36. intSeconds=today.getSeconds();37. if(intHour

12、s=0)38. hours="12:"39. xfile="午夜"40. elseif(intHours<12)41. hours=intHours+":"42. xfile="上午"43. elseif(intHours=12)44. hours="12:"45. xfile="正午"46. else47. intHours=intHours-1248. hours=intHours+":"49. xfile="下午"50. 5

13、1. if(intMinutes<10)52. minutes="0"+intMinutes+":"53. else54. minutes=intMinutes+":"55. 56. if(intSeconds<10)57. seconds="0"+intSeconds+""58. else59. seconds=intSeconds+""60. 61. timeString=xfile+hours+minutes+seconds;62. Clock.innerH

14、TML=timeString;63. window.setTimeout("tick();",100);64. 65. window.onload=tick;66. </SCRIPT>67. <DIVid=Clockstyle="FONT-SIZE:12px;COLOR:#ecc1c1"align=center></DIV>復制代碼四、顯示來訪者的停留時間如:停留時間:00:15XML/HTMIK碼1.2.3. <scriptlanguage="javascript">4. varap_

15、name=navigator.appName;5. varap_vinfo=navigator.appVersion;6. varap_ver=parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(');7.8. vartime_start=newDate();9. varclock_start=time_start.getTime();10. vardl_ok=false;11.12. functioninit()13. 14. if(ap_name="Netscape"&&ap_ver>

16、;=3.0)15. dl_ok=true;16. returntrue;17. 18.19. functionget_time_spent()20. 21. vartime_now=newDate();22. return(time_now.getTime()-clock_start)/1000);23. 24.25. functionshow_secs()/showthetimeuserspentontheside26. 27. vari_total_secs=Math.round(get_time_spent();28. vari_secs_spent=i_total_secs%60;29

17、. vari_mins_spent=Math.round(i_total_secs-30)/60);30. vars_secs_spent=""+(i_secs_spent>9)?i_secs_spent:"0"+i_secs_spent);31. vars_mins_spent=""+(i_mins_spent>9)?i_mins_spent:"0"+i_mins_spent);32. document.fm0.time_spent.value=s_mins_spent+":"+s

18、_secs_spent;33. window.setTimeout('show_secs()',1000);34. 35.36. /->37. </script>38. <FORMname="fm0"onSubmit="0"><FONTCOLOR="#6060FF”>停留日間:39. </FONT><INPUTtype="text"name="time_spent"size=7onFocus="this.blur()&q

19、uot;></FORM>復制代碼而且還要在你主頁源文件<body>中加入下面的代碼1.<BODYonLoad="init();window.setTimeout('show_secs()',1);">復制代碼五、顯示當前日期與時間如:現(xiàn)在是:2008年11月27日14:18:59時間不走動XML/HTMIK碼1.2.3. <scriptlanguage="javascript">4. <!-5. now=newDate()6. hour=now.getHours()7. if(h

20、our<12)8. document.write("現(xiàn)在是:"+now.toLocaleString()9. elseif(hour<18)10. document.write("現(xiàn)在是:"+now.toLocaleString()11. elseif(hour>=18)12. document.write("現(xiàn)在是:"+now.toLocaleString()13. 14. /-></script>復制代碼六、瀏覽器狀態(tài)欄顯示的時鐘如:2:20P.M.星期四在狀態(tài)欄顯示XML/HTMIK碼1.2.

21、3. <BODYonLoad="run();timerONE=window.setTimeout"></BODY>4. <SCRIPTLANGUAGE="javascript">5. <!-Hide6. timelD=null;7. timeRunning=false;8. functionstop()9. if(timeRunning)10. clearTimeout(timelD);11. timeRunning=false;12. 13. functiontime()14. tick=newDate();1

22、5. hours=tick.getHours();16. minutes=tick.getMinutes();17. seconds=tick.getSeconds();18. day=tick.getDay();19. month=tick.getMonth();20. date=tick.getDate();21. year=tick.getYear();22. current=""+(hours>12)?hours-12:hours)23. current+=(minutes<10)?":0":":")+minute

23、s24. current+=(seconds<10)?":0":":")+seconds25. current+=(hours>=12)?"P.M.":"A.M."26. if(day=0)varweekday="星期日"27. if(day=1)varweekday="星期一"28. if(day=2)varweekday="星期二"29. if(day=3)varweekday="星期三"30. if(day=4)var

24、weekday="星期四"31. if(day=5)varweekday="星期五"32. if(day=6)varweekday="星期六"33. current+=(weekday)34. window.status=current;35. timelD=setTimeout("time()",1000);36. timeRunning=true;37. 38. functionrun()39. stop();40. time();41. 42.43. /->44. </SCRIPT>復制代碼

25、七、顯示最后更新時間代碼如:最后更新時間:11/27/200814:21:04XML/HTMIK碼1.2.3. <SCRIPTlanguage=javascript>4. <!-hidescriptfromoldbrowsers5. document.write("最后更新時間:"+document.lastModified+"")6. /endhiding->7. </SCRIPT>復制代碼相關帖子* 征服RIA:函數(shù)式編程的原理收藏分享0* 0* 0* 頂* 踩本是后山人;偶作前堂客。醉舞經(jīng)閣半卷書;坐井說天闊。大

26、志戲功名;海斗量福禍。待到囊中羞澀時;怒指乾坤錯。最快的美國主機,支持支付寶付款,中文面板,無限網(wǎng)站!分享到:人人網(wǎng)QQ空間百度收藏開心網(wǎng)新浪微博Google書簽lht272* 發(fā)短消息* 加為好友lht272(百科“科”家)當前離線UID1728帖子11276精華2積分12831閱讀權限100來自山溝在線時間2374小時注冊時間2009-1-14最后登錄2010-12-14個人空間查看詳細資料版主Rank:7Rank:7Rank:7帖子11276精華2積分12831威望307銀幣42055金幣12647來自山溝在線時間2374小時注冊時間2009-1-14優(yōu)秀版主2#發(fā)表于2010-9-10

27、21:14|只看該作者八、實時走動的數(shù)字時鐘如:下午14:22:03XML/HTMIK碼1. <script>2. functiontick()3. varhours,minutes,seconds,xfile;4. varintHours,intMinutes,intSeconds;5. vartoday;6. today=newDate();7. intHours=today.getHours();8. intMinutes=today.getMinutes();9. intSeconds=today.getSeconds();10. if(intHours=0)11. hou

28、rs="12:"12. xfile="午夜";13. elseif(intHours<12)14. hours=intHours+":"15. xfile="上午";16. elseif(intHours=12)17. hours="12:"18. xfile="正午";19. else20. intHoursintHours=intHours-1221. hours=intHours+":"22. xfile="下午"23. 2

29、4. if(intMinutes<10)25. minutes="0"+intMinutes+":"26. else27. minutes=intMinutes+":"28. 29. if(intSeconds<10)30. seconds="0"+intSeconds+""31. else32. seconds=intSeconds+""33. 34. timeString=xfile+hours+minutes+seconds;35. Clock.innerH

30、TML=timeString;36. window.setTimeout("tick();",100);37. 38. window.onload=tick;39. </script>40.41. <divid="Clock"style="font-size:20;color:#000000"></div>復制代碼九、根據(jù)不同的時間顯示不同的問候語如:午安XML/HTMIK碼方法:在主頁中你需要的地方加入以下代碼:1.2.3. <scriptlanguage="LiveScript&

31、quot;>4. now=newDate(),hour=now.getHours()5. if(hour<6)document.write("明天不用上班了嗎?")6. elseif(hour<8)document.write("全新的一天!")7. elseif(hour<12)document.write("8. elseif(hour<14)document.write("9. elseif(hour<18)document.write("10. elseif(hour<22)

32、document.write("11. elseif(hour<24)document.write("12. /->13. </script>復制代碼說明,可以自行修改出更好更多的問候語!十、顯示年月日星期及農(nóng)歷的月和日如:第一步:將一下代碼保存為.JS文件XML/HTMIK碼早安!")外面太陽大嗎?")午安!")晚上好!")夜深了!要注意身體呀!祝你做個好夢!")2008年11月27日星期四農(nóng)歷10月30日1. <!-2. functionCalConv()3. 4. FIRSTYEAR=19

33、98;5. LASTYEAR=2031;6.7. today=newDate();8. SolarYear=today.getFullYear();9. SolarMonth=today.getMonth()+1;10. SolarDate=today.getDate();11. Weekday=today.getDay();12. LunarCal=13. newtagLunarCal(27,5,3,43,1,0,0,1,0,0,1,1,0,1,1,0,1),14. newtagLunarCal(46,0,4,48,1,0,0,1,0,0,1,0,1,1,1,0,1),/*88*/15. n

34、ewtagLunarCal(35,0,5,53,1,1,0,0,1,0,0,1,0,1,1,0,1),/*89*/16. newtagLunarCal(23,4,0,59,1,1,0,1,0,1,0,0,1,0,1,0,1),17. newtagLunarCal(42,0,1,4,1,1,0,1,0,1,0,0,1,0,1,0,1),18. newtagLunarCal(31,0,2,9,1,1,0,1,1,0,1,0,0,1,0,1,0),19. newtagLunarCal(21,2,3,14,0,1,0,1,1,0,1,0,1,0,1,0,1),/*93*/20. newtagLunar

35、Cal(39,0,5,20,0,1,0,1,0,1,1,0,1,0,1,0,1),21. newtagLunarCal(28,7,6,25,1,0,1,0,1,0,1,0,1,1,0,1,1),22. newtagLunarCal(48,0,0,30,0,0,1,0,0,1,0,1,1,1,0,1,1),23. newtagLunarCal(37,0,1,35,1,0,0,1,0,0,1,0,1,1,0,1,1),/*97*/24. newtagLunarCal(25,5,3,41,1,1,0,0,1,0,0,1,0,1,0,1,1),25. newtagLunarCal(44,0,4,46,

36、1,0,1,0,1,0,0,1,0,1,0,1,1),26. newtagLunarCal(33,0,5,51,1,0,1,1,0,1,0,0,1,0,1,0,1),27. newtagLunarCal(22,4,6,56,1,0,1,1,0,1,0,1,0,1,0,1,0),/*101*/28. newtagLunarCal(40,0,1,2,1,0,1,1,0,1,0,1,0,1,0,1,0),29. newtagLunarCal(30,9,2,7,0,1,0,1,0,1,0,1,1,0,1,0,1),30. newtagLunarCal(49,0,3,12,0,1,0,0,1,0,1,1

37、,1,0,1,0,1),31. newtagLunarCal(38,0,4,17,1,0,1,0,0,1,0,1,1,0,1,1,0),/*105*/32. newtagLunarCal(27,6,6,23,0,1,0,1,0,0,1,0,1,0,1,1,1),33. newtagLunarCal(46,0,0,28,0,1,0,1,0,0,1,0,1,0,1,1,0),34. newtagLunarCal(35,0,1,33,0,1,1,0,1,0,0,1,0,0,1,1,0),35. newtagLunarCal(24,4,2,38,0,1,1,1,0,1,0,0,1,0,1,0,1),/

38、*109*/36. newtagLunarCal(42,0,4,44,0,1,1,0,1,0,1,0,1,0,1,0,1),37. newtagLunarCal(31,0,5,49,1,0,1,0,1,1,0,1,0,1,0,1,0),38. newtagLunarCal(21,2,6,54,0,1,0,1,0,1,0,1,1,0,1,0,1),39. newtagLunarCal(40,0,0,59,0,1,0,0,1,0,1,1,0,1,1,0,1),/*113*/40. newtagLunarCal(28,6,2,5,1,0,1,0,0,1,0,1,0,1,1,1,0),41. newt

39、agLunarCal(47,0,3,10,1,0,1,0,0,1,0,0,1,1,1,0,1),42. newtagLunarCal(36,0,4,15,1,1,0,1,0,0,1,0,0,1,1,0,1),43. newtagLunarCal(25,5,5,20,1,1,1,0,1,0,0,1,0,0,1,1,0),/*117*/44. newtagLunarCal(43,0,0,26,1,1,0,1,0,1,0,1,0,0,1,0,1),45. newtagLunarCal(32,0,1,31,1,1,0,1,1,0,1,0,1,0,1,0,0),46. newtagLunarCal(22

40、,3,2,36,0,1,1,0,1,0,1,1,0,1,0,1,0);47. /*年每月之日數(shù)*/48. SolarCal=31,28,31,30,31,30,31,31,30,31,30,31;49.50. /*年每月之累稹日數(shù),平年典閨年*/51. SolarDays=0,31,59,90,120,151,181,212,243,273,304,334,365,396,0,31,60,91,121,152,182,213,244,274,305,335,366,397;52. AnimalIdx="馬","羊","猴","

41、;雞","狗","豬","鼠","牛","虎","兔","龍","蛇"53. LocationIdx="南","東","北","西"54. if(SolarYear<=FIRSTYEAR|SolarYear>LASTYEAR)return1;55. sm=SolarMonth-1;56. if(sm<0|sm>11)retu

42、rn2;57. leap=GetLeap(SolarYear);58. if(sm=1)59. d=leap+28;60. else61. d=SolarCalsm;62. if(SolarDate<1|SolarDate>d)return3;63. y=SolarYear-FIRSTYEAR;64. acc=SolarDaysleap*14+sm+SolarDate;65. kc=acc,+LunarCaly.BaseKanChih;66. Kan=kc%10;67. Chih=kc%12;68. Location=LocationIdxkc%4;69. Age=kc%60;70.

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論