<p align=center><font size=6 face="黑体"><b>2013年情人节</b></font></p>
<script language=JavaScript> 
<!--
var now = new Date();             function currenttime() 

var dtime = new Date("2/14/2013");    
now.setTime(now.getTime()+100); 
days = (dtime - now) / 1000 / 60 / 60 / 24;    
daysRound = Math.floor(days); 
hours = (dtime - now) / 1000 / 60 / 60 - (24 * daysRound);    
hoursRound = Math.floor(hours); 
minutes = (dtime - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);    
minutesRound = Math.floor(minutes); 
if(minutesRound<=9)
minutesRound="0"+minutesRound
seconds = (dtime - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.floor(seconds); 
if(secondsRound<=9)
secondsRound="0"+secondsRound
time.innerHTML = daysRound + "天" +hoursRound + "小时" + minutesRound + "分" + secondsRound + "秒";    
}
setInterval("currenttime()",100); 
//-->
</script> 
<p align=center>距离2013年2月14日还有<span id="time"></span></p>

解决方案 »

  1.   


    (function(w){
    if(w.BindDate)return;
    w.BindDate=function(dom)
    {
    if(dom.Timer)return;
    dom.Timer= setInterval(function(){SetDate(dom)},100);
    }
    var SetDate=function(dom){var dtime = new Date("2/14/2013");    
    now.setTime(now.getTime()+100); 
    days = (dtime - now) / 1000 / 60 / 60 / 24;    
    daysRound = Math.floor(days); 
    hours = (dtime - now) / 1000 / 60 / 60 - (24 * daysRound);    
    hoursRound = Math.floor(hours); 
    minutes = (dtime - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);    
    minutesRound = Math.floor(minutes); 
    if(minutesRound<=9)
    minutesRound="0"+minutesRound
    seconds = (dtime - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
    secondsRound = Math.floor(seconds); 
    if(secondsRound<=9)
    secondsRound="0"+secondsRound
    dom.innerHTML = daysRound + "天" +hoursRound + "小时" + minutesRound + "分" + secondsRound + "秒";    
    }
    })(window)
      

  2.   

    新建一个文本文件,拷贝js 代码,另存为.js 文件就可以。
      

  3.   

    <p align=center><font size=6 face="黑体"><b>2013年情人节</b></font></p>
    <p align=center>距离2013年2月14日还有<span id="time"></span></p>
    <script src="name.js"></script>name.js
    var now = new Date();
    function currenttime()
    {
    var dtime = new Date("2/14/2013");    
    now.setTime(now.getTime()+100); 
    days = (dtime - now) / 1000 / 60 / 60 / 24;    
    daysRound = Math.floor(days); 
    hours = (dtime - now) / 1000 / 60 / 60 - (24 * daysRound);    
    hoursRound = Math.floor(hours); 
    minutes = (dtime - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);    
    minutesRound = Math.floor(minutes); 
    if(minutesRound<=9)
    minutesRound="0"+minutesRound
    seconds = (dtime - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
    secondsRound = Math.floor(seconds); 
    if(secondsRound<=9)
    secondsRound="0"+secondsRound
    time.innerHTML = daysRound + "天" +hoursRound + "小时" + minutesRound + "分" + secondsRound + "秒";    
    }
    setInterval("currenttime()",100);