1. Create part1.html
1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=gb2312" />5 <title>Use of Date objects-clock effects</title>6 <Scripttype= "Text/javascript">7 window.onload=function(){8 //gets the first input label9 varInputone=document.getElementsByTagName ("input")[0];Ten One //Add a Click event to the input tag A Inputone.onclick=function(){ - SetTimeout ("Timefun ()", -); - } the - //get the 2nd input tag - varInputtwo=document.getElementsByTagName ("input")[1]; - + //Add a Click event to the input tag - varTimestr; + Inputtwo.onclick=function(){ A Timestr=SetInterval ("Timefun ()", +); at } - - //get the 2nd input tag - varInputthree=document.getElementsByTagName ("input")[2]; - - //Add a Click event to the input tag in Inputthree.onclick=function(){ - clearinterval (TIMESTR); to } + - } the * functionTimefun () { $ varDate=NewDate ();Panax Notoginseng var Year=date.getfullyear ();//get four-bit year - varMonth=Date.getmonth ()+1; //Month the var Day=date.getdate ();//one day in one months, range 1-31 + varWeek=Date.getday ();//Week A varHour=date.gethours ();//number of hours, 24 binary the varminutes=date.getminutes ();//minutes + varSecond=date.getseconds (); //seconds - var Time= Year+"years" $ +Month+"Month" $ + Day+"Day Week"+Week+" " - +Hour+"when"+minutes+"points"+Second+"seconds"; - Console.log (time); the document.getElementsByTagName ("Div")[0].innerhtml=Time ; - Wuyi the } - </Script> Wu </Head> - About <Body> $ <inputtype= "button"value= "appears after 3 seconds"/> - <inputtype= "button"value= "Dynamic Clock"/> - <inputtype= "button"value= "Stop Clock"/> - <DivID= "Time"> A </Div> + </Body> the </HTML>
Date object implements clock effects
2.
3. Click "Three seconds to appear"
4. Click on the dynamic clock
5, click Stop Clock, Time will stop each second refresh
3. Data Object