[网页高手]
Homepage
[网络编程]
Programe
[图形图像]
Picture
[冲浪宝典]
Insernet
[操作系统]
System
[软件教学]
Software
[数码时代]
Didgtale
[安全防御]
Didgtale
[IT学院]
Education
    
 
Google Web tongyi.net
 
    你的位置:首页 > 网页高手 > HTML > 在网页中制作动态时间按钮
网页高手
  Dreamweaver

FrontPage

Javascript

HTML

CSS

XML

心得技巧

DHTML

 
在网页中制作动态时间按钮

本文采用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〉
     打印本文 | 推荐朋友 | 收藏文章 | 关闭窗口
 
 

    相关文章
 网页中取消鼠标右键方法大全    (2001年7月10日)

 页面特效之--夜晚的星空    (2001年7月10日)

 XHTML 1.0:标记新的开端    (2001年7月8日)

 网页制作源码三则    (2001年7月8日)

 如何在HTML页面中使用js文件    (2001年6月10日)

 ASP.NET中的HTML编码和URL编码    (2001年5月8日)

 HTML 注释    (2001年3月22日)

 当心!HTML文件也能格式化硬盘    (2001年2月20日)

 
 

 

关于统一 | 联系合作 | 统一作品 | 版权申明 | 建站服务 | 更多说明
Copyright 2000-2003 Tongyi All rights reserved. 京ICP备05005608号