在网页中制作动态时间按钮
作者:元晋豫 来源:ccidnet.com 添加时间:2006-5-21 9:38:48源代码如下:
| 〈html〉〈head〉 〈title〉时间按钮示例〈/title〉 〈script language=vbscript〉 dim stt,edt ′---| 显示动态时间按钮 |--- sub disp—clock() dim hr,sx,hrs,curtime hr=hour(time) if hr〈12 then hrs=cstr(hr) sx=″ am″ else hrs=cstr(hr-12) sx=″ pm″ end if curtime=hrs+right(cstr(time),6) yt.value=curtime+sx call settimeout(″disp—clock()″,1000) end sub ′---| 显示停留时间数 |--- sub disp—msg() dim hr,mn,sc,hrs,mns edt=time hr=hour(edt) mn=minute(edt) sc=second(edt)-second(stt) if sc〈0 then sc=60+sc mn=mn-1 end if mn=mn-minute(stt) if mn〈0 then mn=60+mn hr=hr-1 end if hr=hr-hour(stt) if hr〈0 then hr=24+hr hrs=″ ″+cstr(hr)+″小时″ if hr=0 then hrs=″″ mns=cstr(mn)+″分钟″ if mn=0 then mns=″″ msgbox ″你在本网页已停留了″+hrs+mns+cstr(sc)+″秒!″ end sub 〈/script〉 〈/head〉 〈body〉 〈center〉 〈br〉〈br〉〈p〉〈font color=red〉〈b〉〈h3〉时间按钮〈/h3〉〈/b〉〈/font〉〈/p〉 〈input type=″button″ value=″″ name=″yt″ onclick=″disp_msg()″ style=″cursor:hand; font-family: 黑体; font-size: 16pt; font-weight: bold; color:blue″〉 〈p〉〈h5〉提示:鼠标单击按钮会显示停留时间!〈/h5〉〈/p〉 〈script language=vbscript〉 stt=time disp—clock 〈/script〉〈/center〉 〈/body〉 〈/html〉 |
站内搜索