设为首页   加入最爱           最新更新:全方位英文文章资料库
 
资料坊搜索: 标题 全文     
在网页中制作动态时间按钮
   首页>>YesizeCOM>>电脑技能坊>>HTML>>正文       
 
广告招租,e-mail:yesize@hotmail.com

广告招租,e-mail:yesize@hotmail.com

本文采用vbscript脚本语言编程实现动态时间按钮,其原理就是调用定时函数settimeout()每隔一秒钟获取一次系统时间,并及时改变网页中按钮的value值,从而实现时间的动态显示。当鼠标在时间按钮上单击时,程序将计算从打开网页到当前的停留时间,并显示给用户。本例在ie4.0以上通过。

源代码如下:

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

上一篇:图片隐现效果代码 下一篇:网页中取消鼠标右键方法大全

版权说明:作品来源于网上,版权归作者所有,如果无意中侵犯了您的版权,请来信告知,本站将在3个工作日内删除。yesize@hotmail.com
  热门小游戏分类 
射击小游戏 连连看小游戏
台球小游戏 成人小游戏
CS小游戏 化妆小游戏
赛车小游戏 休闲小游戏
篮球小游戏 换装小游戏
儿童小游戏 牛牛小游戏
麻将小游戏 冒险小游戏
美媚小游戏 益智小游戏
体育小游戏  
Society Recreation & Sports
Travel & Leisure Communications
Vehicles Computers
Fashion Arts & Entertainment
Reference & Education Disease & Illness
Writing & Speaking Politics
Product Reviews Food & Beverage
Finance Internet Business
Self Improvement Home & Family
Health & Fitness Business
最新更新内容
警惕“公务员报考热”背
公务员考试不是丈母娘考
一名新公务员的自白:我
公务员考脑筋急转弯与挂
北努斗:2006行政能力测
大讨论:06行测BT题目大
过来人回忆:当年,我也
一家之言:公务员热折射
公务员考试申论要是有正
数十万大学生走进公务员
      粤ICP备05005424         Copyright ©2000 - 2004 Yesize.COM