首页 > 代码库 > html倒计时 照着练习(抄袭)的

html倒计时 照着练习(抄袭)的

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>倒计时</title><link rel="stylesheet" type="text/css" href="倒计时.css" /><script type="text/javascript">    function daojishi(){        var nowday=new Date();//现在        var endday;//截止日期        var endy=parseInt(document.getElementById("t1").value);        var endmo=parseInt(document.getElementById("t2").value);        var endd=parseInt(document.getElementById("t3").value);        var endh=parseInt(document.getElementById("t4").value);        var endm=parseInt(document.getElementById("t5").value);        var ends=parseInt(document.getElementById("t6").value);        //月份减1        endday=new Date(endy,endmo-1,endd,endh,endm,ends);        //endday=new Date(2014,11,8,17,55,0);        //总秒数ts        //document.getElementById("main").innerHTML=endday-nowday;        var ts=Math.round((endday-nowday)/1000);        //总天数        var td=parseInt(ts/3600/24);        //零几小时        var eh=parseInt((ts%(3600*24))/3600);        //零几分钟        var em=parseInt((ts%3600)/60);        //零几秒        var es=ts%60;        document.getElementById("box").innerHTML="还剩"+td+""+eh+""+em+""+es+"";                        if(ts<0){            alert("倒计时结束");            return;        }        window.setTimeout("daojishi()",1000);        }    </script></head><body>    <h1 align="center">请输入截止日期的年月日,时分秒</h1>    <div id="main">        <input type="text" id="t1"/><input type="text" id="t2"/><input type="text" id="t3"/><input type="text" id="t4"/><input type="text" id="t5"/><input type="text" id="t6"/></div>    <button id="b" onclick="daojishi()">开始倒计时</button>    <div id="box">        </div></body></html>

 

html倒计时 照着练习(抄袭)的