1 / 7

JavaScript 技术 ——

JavaScript 技术 ——. 如何在网页中显示当前系统时间. 电子信息工程学院 龚卫 E_mail:gongwei@cqdd.cq.cn. 教学内容. 本课程主要学习利用 javascript 技术在网页中显示当前系统时间。 1 、实例效果 2 、实现方法 3 、程序解释 4 、语法说明 5 、课后练习. 1 、实例效果. 打开网页页面后,就会出现显示当前 系统时间 ,包括** :( 小时 )**:( 分钟 )**( 秒 )( 上午 / 下午 / 晚上 / 深夜 ) ,时间显示与计算机同步。. 2 、实现方法. 用记事本打开效果网页。.

marnin
Download Presentation

JavaScript 技术 ——

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaScript技术—— 如何在网页中显示当前系统时间 电子信息工程学院 龚卫 E_mail:gongwei@cqdd.cq.cn

  2. 教学内容 本课程主要学习利用javascript技术在网页中显示当前系统时间。 1、实例效果 2、实现方法 3、程序解释 4、语法说明 5、课后练习

  3. 1、实例效果 打开网页页面后,就会出现显示当前系统时间,包括**:(小时)**:(分钟)**(秒)(上午/下午/晚上/深夜),时间显示与计算机同步。

  4. 2、实现方法 用记事本打开效果网页。

  5. 3、程序解释 该实例主要利用new date()来创建对象,然后利用date对象的getHours()、getMinutes()、getSeconds()方法来实现显示当前的时间,利用document.clock.face.value=timevalue向浏览器写入当前时间,最后利用setTimeout(“showtime()”,1000)使页面每隔1s变化一次,这样就实现了网页时钟效果。

  6. 4、语法说明 • getHours()方法获取24小时制的小时数,范围0-23; • getMinutes()方法获取分钟数,范围0-59; • getSeconds()方法获取秒数,范围0-59; • setTimeout(函数,时间)能够每隔一定时间(ms)调用函数一次,且只调用一次。

  7. 5、课后练习 请各位同学利用javascript技术实现“在网页中显示当前日期和时间”的特效。要求: • 日期和时间与计算机系统同步。 • 日期和时间格式 如“2014年05月18日星期日 上午10:05:30”所示。

More Related