Use of JS Timer--Digital clock

Source: Internet
Author: User

<title>Untitled Document</title><Script>functionTodou (n) {if(n<Ten){        return '0'+N; }Else{            return "'+N; //guaranteed to return strings, avoid putting them together and adding them.}}window.onload=function (){    varaimg=document.getElementsByTagName ('img'); functiontick () {varodate=NewDate (); varStr=Todou (Odate.gethours ())+Todou (Odate.getminutes ())+Todou (Odate.getseconds ());  for(varI=0; I<Aimg.length;i++) {aimg[i].src='images/'+Str.charat (i)+'. gif'; }} setinterval (tick, +);    Tick (); };</Script></Head><Bodystyle= "background: #999; color:white;"><imgsrc= "Images/0.gif"><imgsrc= "Images/0.gif">:<imgsrc= "Images/0.gif"><imgsrc= "Images/0.gif">:<imgsrc= "Images/0.gif"><imgsrc= "Images/0.gif"></Body>

Minor problem:
var str= ' abcdef ';
Alert (str[0]); Show undefined under IE7
Use Str.charat (0) to solve this compatibility problem

Digital clock
Get system time
Date Object
GetHours, getminutes, getseconds
Date Object Other methods
Year getFullYear ()
Month GetMonth () starting from 0
Day GetDate ()
Week GetDay () 0,1,2,3,4,5,6 0 for weekend

Use of JS Timer--Digital clock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.