Js webpage time code-supports code walking in seconds

Source: Internet
Author: User
Tip: you can modify some code before running

<SCRIPT LANGUAGE="JavaScript"><!-- Activate Cloaking /* Javascript Countdown Timer (version 1.0) Copyright (C) 1997 Andrew Turi All Rights Reserved. Permission given to use this script provided that this copyright notice remains in tact. [E-mail: andrew@2-cool.com]*/var timerID;var timerRunning = false;var today = new Date();var count = new Date();var secPerDay = 0;var minPerDay = 0;var hourPerDay = 0;var secsLeft = 0;var secsRound = 0;var secsRemain = 0;var minLeft = 0;var minRound = 0;var dayRemain = 0;var minRemain = 0;var Expire = 0;var timeRemain = 0;var timeUp = "Type Anything You Want" // enter text to be displayed when countdown is finishedvar time = "0 days, 0 hours, 0 minutes, 0 seconds" //do not modify this textfunction stopclock (){if(timerRunning)clearTimeout(timerID);timerRunning = false;}function startclock () {stopclock();showtime();}function showtime () {today = new Date();count = new Date("December 5, 2007 12:00"); // enter date to count down to (use the same format)count.setYear(today.getYear());secsPerDay = 1000 ;minPerDay = 60 * 1000 ;hoursPerDay = 60 * 60 * 1000;PerDay = 24 * 60 * 60 * 1000;Expire = (count.getTime() - today.getTime())/*Seconds*/secsLeft = (count.getTime() - today.getTime()) / minPerDay;secsRound = Math.round(secsLeft);secsRemain = secsLeft - secsRound;secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60;secsRemain = Math.round(secsRemain);/*Minutes*/minLeft = ((count.getTime() - today.getTime()) / hoursPerDay);minRound = Math.round(minLeft);minRemain = minLeft - minRound;minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain = ((minLeft - minRound) * 60);minRemain = Math.round(minRemain - 0.495);/*Hours*/hoursLeft = ((count.getTime() - today.getTime()) / PerDay);hoursRound = Math.round(hoursLeft);hoursRemain = hoursLeft - hoursRound;hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);hoursRemain = Math.round(hoursRemain - 0.5);/*Days*/daysLeft = ((count.getTime() - today.getTime()) / PerDay);daysLeft = (daysLeft);daysRound = Math.round(daysLeft);daysRemain = daysRound;/*Fixes*/if (daysRemain == 1) daysRemain = daysRemain + " day, "; else daysRemain = daysRemain + " days, "; if (hoursRemain == 1) hoursRemain = hoursRemain + " hour, "; else hoursRemain = hoursRemain + " hours, ";if (minRemain == 1) minRemain = minRemain + " minute, "; else minRemain = minRemain + " minutes, ";if (secsRemain == 1) secsRemain = secsRemain + " second"; else secsRemain = secsRemain + " seconds";/*Time*/timeRemain = daysRemain + hoursRemain + minRemain + secsRemain;window.status = "";document.clock.face.value = timeRemain;timerID = setTimeout("showtime()",1000);timerRunning = true;if (Expire <= 0){document.clock.face.value = time; // choose either "time" or "timeUp" (without quotes)stopclock()}}// De-activate Cloaking -->// --></sCRIPT><table width=420><tr><td align=center><FORM NAME="clock"><INPUT TYPE="text" SIZE="41" NAME="face"></fORM><SCRIPT LANGUAGE="JavaScript"><!--//document.write('<FORM NAME="clock"><INPUT TYPE="text" SIZE="41" NAME="face"></fORM>');startclock()// --></sCRIPT><p>In this case the countdown is to december5, 2007.</p></td></tr></table>
Tip: you can modify some code before running

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.