Using JS function to make clock running program

Source: Internet
Author: User

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Clock</title>    <Scripttype= "Text/javascript">    functiontodouble (num)//Less than two bits, empty 0 {if(Num<Ten)        {            return '0'+num;//a number in front plus 0, it becomes two digits}Else        {            return "'+num; }} window.onload=function()//program main run content {varobtn=document.getElementById ('BTN1'); varaimg=document.getElementsByTagName ('img'); varI=0; functionUpdateTime () {varodate=Newdate ();//Get system timevarStr=todouble (Odate.gethours ())+todouble (Odate.getminutes ())+todouble (Odate.getseconds ()); //alert (str);             for(i=0; I<Aimg.length;i++) {aimg[i].src='img/'+Str.charat (i)+'. PNG';//Set Picture path using Charat method}} SetInterval (UpdateTime, +);//automatically follow the system time to refresh UpdateTime (),//To avoid the page refresh time to stay 1 seconds wait}; </Script></Head><Bodystyle= "color: #FFFF00; background: #990099; font-size:30px;">    <imgsrc= "C:\Users\Administrator\Desktop\ exercise file \ Digital Clock \img\0.png"/>    <imgsrc= "C:\Users\Administrator\Desktop\ exercise file \ Digital Clock \img\0.png"/>Point<imgsrc= "C:\Users\Administrator\Desktop\ exercise file \ Digital Clock \img\0.png"/>    <imgsrc= "C:\Users\Administrator\Desktop\ exercise file \ Digital Clock \img\0.png"/>points<imgsrc= "C:\Users\Administrator\Desktop\ exercise file \ Digital Clock \img\0.png"/>    <imgsrc= "C:\Users\Administrator\Desktop\ exercise file \ Digital Clock \img\0.png"/>seconds</Body></HTML>

Running results such as:

Using JS function to make clock running program

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.