當前位置:編程學習大全網 - 源碼下載 - 如何用vbscript做壹個在頁面上動態顯示時間的程序啊

如何用vbscript做壹個在頁面上動態顯示時間的程序啊

下面這個代碼是顯示壹個按鈕,按鈕上顯示當前時間,點擊顯示停留時間。

<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>

<input type="button" value="" name="yt" onclick="disp_msg()">

<p><h5>提示:鼠標單擊按鈕會顯示停留時間!</h5></p>

<script language=vbscript>

stt=time

disp_clock

</script>

如果妳只是想動態顯示時間,可以把下面代碼加入妳的頁面:

<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.innerHTML=curtime+sx

call settimeout("disp_clock()",1000)

end sub

</script>

<script language=vbscript>

stt=time

disp_clock

</script>

然後在需要出現時間的地方放上<span id="yt"></span>即可。

  • 上一篇:工廠有SMT防錯料系統可以不做首檢嗎?
  • 下一篇:p2p網貸軟件系統開發得多少錢?
  • copyright 2024編程學習大全網