JS implementation of the Countdown Clock sample code

Source: Internet
Author: User
Tags visibility

  This article is mainly on the JS Countdown Clock sample code is introduced, the need for friends can come to the reference, I hope to help you.

As follows: The code is: <!--add the following code to the HTML <Body></Body>-->   <script language=javascript1.2> function Setcountdown (theyear,themonth,theday) {yr=theyear;mo=themonth;da=theday} setcountdown (2008,7,12) var Occasion= "2008 Beijing Olympic Games" var message_on_occasion= "The long-awaited moment has finally arrived!" var countdownwidth= ' 480px ' var countdownheight= ' 20px ' var countdownbgcolor= ' Tan ' var opentags= ' <font face= ' song body ' ><small> ' var closetags= ' </small></font > ' var montharray=new Array ("The", "Feb", "Mar", "APR", "may", "June", "may", "Aug", "Sep", "Oct", "Nov", "Dec") var Crosscount= ' function Start_countdown () {if (document.layers) document.countdownnsmain.visibility= "show" Else if ( document.all| | document.getElementById) Crosscount=document.getelementbyid&&!document.all?document.getelementbyid (" Countdownie "): Countdownie Countdown ()}   if (document.all| | document.getElementById) document.write (' <span id= "Countdownie" style= "width: ' +countdownwidth+ '; Background-color: ' +countdownbgcolor+ ' ></span> ')   Window.onload=start_countdown     function countdown () {var today=new Date () var Todayy=today.getyear () if (Todayy < 1000) todayy+=1900 var todaym=today.getmonth () var todayd=today.getdate () var toda Yh=today.gethours () var todaymin=today.getminutes () var todaysec=today.getseconds () var todaystring=montharray[ todaym]+ "+todayd+", "+todayy+" "+todayh+": "+todaymin+": "+todaysec futurestring=montharray[mo-1]+" "+da+", "+yr dd= Date.parse (futurestring)-date.parse (todaystring) Dday=math.floor (dd/(60*60*1000*24) *1) Dhour=Math.floor (dd% (60* 60*1000*24))/(60*60*1000) *1) Dmin=math.floor ((dd%, 60*60*1000*24)% (60*60*1000))/(60*1000) *1) Dsec=math.floor (( (dd% (60*60*1000*24))% ( 60*60*1000)% (60*1000))/1000*1) if (dday<=0&&dhour<=0&&dmin<=0&&dsec<=1& &todayd==da) {if (document.layers) {Document.countdownnsmain.document.countdownnssub.document.write (opentags+ Message_on_occasion+closetags) Document.countdownnsmain.documEnt.countdownnssub.document.close ()} else if (document.all| | document.getElementById) Crosscount.innerhtml=opentags+message_on_occasion+closetags return} else if (dday<=-1) { if (document.layers) {document.countdownnsmain.document.countdownnssub.document.write (opentags+ "Time has passed!") +closetags) Document.countdownnsmain.document.countdownnssub.document.close ()} else if (document.all| | document.getElementById) crosscount.innerhtml=opentags+ "Occasion already passed! "+closetags return} else{if (document.layers) {Document.countdownnsmain.document.countdownnssub.document.write ( Opentags+dday+ "Days," +dhour+ "hours," +dmin+ "minutes, and" +dsec+ "seconds left until" +occasion+closetags) document.c Ountdownnsmain.document.countdownnssub.document.close ()} else if (document.all| | document.getElementById) crosscount.innerhtml=opentags+ "+dday+" Days, "+dhour+" hours, "+dmin+" points, "+dsec+" Seconds is "+occasion" +closetags} settimeout ("Countdown ()", 1000)} </SCRIPT> <script type= "Text/javascript"Src= "" ></SCRIPT> <script language= "JavaScript" > <!--  baiduwritead ("Zouwenyedg", "3"); -->  </SCRIPT>     <ilayer id=countdownnsmain visibility= "Hide" bgcolor= "&{ Countdownbgcolor}; "   height= "&{countdownheight};" width= "&{countdownwidth};" ><LAYER  id=countdownnssub height= "&{countdownheight};"   width= "&{countdownwidth};" top= "0" left= "0" ></LAYER></ILAYER>    

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.