<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>倒计时 &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/%E5%80%92%E8%AE%A1%E6%97%B6/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Tue, 22 Jan 2013 06:23:51 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.1</generator>
	<item>
		<title>Javascript的setInterval和clearInterval应用</title>
		<link>https://www.mudbest.com/javascript%e7%9a%84setinterval%e5%92%8cclearinterval%e5%ba%94%e7%94%a8/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Tue, 22 Jan 2013 06:17:43 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[clearInterval]]></category>
		<category><![CDATA[setInterval]]></category>
		<category><![CDATA[倒计时]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1753</guid>

					<description><![CDATA[时间间隔可以用 setInterval 命令来创建并用 clearInterval 命令来终止。setInte ... <a title="Javascript的setInterval和clearInterval应用" class="read-more" href="https://www.mudbest.com/javascript%e7%9a%84setinterval%e5%92%8cclearinterval%e5%ba%94%e7%94%a8/" aria-label="阅读 Javascript的setInterval和clearInterval应用">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>时间间隔可以用 setInterval 命令来创建并用 clearInterval 命令来终止。setInterval 所用的参数有两种格式。在第一种格式中，你传递给 setInterval 的参数可以是一个函数名，一段时间上的间隔以及一些传递给前面函数的相关参数。当 setInterval 运行时它会依照规定的时间间隔依次将列出的参数传递给指定的函数，直到你调用 clearInterval 将其终止。相关的示范代码<span id="more-1753"></span>如下： </p>
<pre class="brush: jscript; title: ; notranslate">
function updateStockPrices(whichStock) { 
    // Update code here 
    trace('Updating prices for '+whichStock); 
} 
stockInterval = setInterval(updateStockPrices, 1000, &quot;Stratford Flash Products&quot;);
</pre>
<p>setInterval全面的介绍<br />
setInterval动作的作用是在播放动画的时，每隔一定时间就调用函数，方法或对象。可以使用本动作更新来自数据库的变量或更新时间显示。setInterval动作的语法格式如下： </p>
<p>setInterval(function,interval[,arg1,arg2,&#8230;&#8230;argn])<br />
setInterval(object,methodName,interval[,arg1,arg2,&#8230;..argn]) </p>
<p>第一种格式是标准动作面板中setInterval函数的默认语法，第二种格式是在专家模式动作中使用的方法。<br />
其中的参数function是一个函数名或者一个对匿名函数的引用。object参数指定从Object对象派生的对象。methodName制定object参数中要调用的方法。interval制定对function或methodName调用两次之间的时间，单位是毫秒。后面的arg1等是可选的参数，用于制定传递给function或是methodName的参数。<br />
setInterval它设置的时间间隔小于动画帧速（如每秒10帧，相当于100毫秒），则按照尽可能接近interval的时间间隔调用函数。而且必须使用updateAfterEvent动作来确保以足够的频率刷新屏幕。如果interval大于动画帧速，则只用在每次播放头进入某一帧是才调用，以减小每次刷新屏幕的影响。<br />
下面的例子每隔1秒调用一次匿名函数。 </p>
<p>setInterval(function(){trace(&#8220;每隔1秒钟我就会显示一次&#8221;)},1000);//这里的function(){}是没有函数名<br />
的函数。成为匿名函数，后面的1000是时间间隔，单位是毫秒。<br />
下面的例子为我们展示如何带参数运行。 </p>
<pre class="brush: jscript; title: ; notranslate">
function show1(){ 
    trace(&quot;每隔1秒我就会显示一次&quot;); 
} 
function show2(str){ 
    trace(str); 
} 
setInterval(show1,1000); 
</pre>
<p>setInterval(show2,2000,&#8221;每隔2秒我就会显示一次&#8221;);<br />
上面已经将函数的setInterval方法介绍了。<br />
下面我们将介绍对象的setInterval方法。<br />
首先，写一个setInterval在动作中调用对象的方法的例子，该例子不需要传递参数。 </p>
<pre class="brush: jscript; title: ; notranslate">
myobj=new Object();//创建一个新的对象 
myobj.interval=function){ 
trace(&quot;每隔1秒我就会显示一次&quot;); 
}//创建对象的方法。 
setInterval(myobj,&quot;interval&quot;,1000);//设定时间间隔调用对象的方法。 
</pre>
<p>接下来介绍如何传递参数。其实道理和函数的传递参数是一样的。 </p>
<pre class="brush: jscript; title: ; notranslate">
myobj=new Object(); 
myobj.interval-function(str){ 
    trace(str); 
} 
setInterval(myobj,&quot;interval&quot;,2000,&quot; 每隔2秒我就会显示一次&quot;); 
</pre>
<p>注意。要调用为对象定义的方法时，必须在专家模式中使用第二种语法格式。<br />
这样子的话呢，我们来作一个动态显示时间的画面。可以用下面的代码实现。 </p>
<pre class="brush: jscript; title: ; notranslate">
setInterval(show,1000); 
function show(){ 
    time=new Date(); 
    hour=time.getHours(); 
    minu=time.getMinutes(); 
    sec=time.get.Seconds(); 
    datetime=hour &quot;:&quot; minu &quot;:&quot; sec; 
}
//这里的datetime是一个动态文本框的变量名字。 
</pre>
<p>这样子呢，setInterval这个方法大家应该学的很好了。现在呢，我们学习clearInterval.<br />
clearInterval动作的作用是清楚对setInterval函数的调用，它的语法格式如下clearInterval(intervalid);intervalid是调用setInterval函数后返回的对象。<br />
下面举一个简单的例子。 </p>
<pre class="brush: jscript; title: ; notranslate">
function show(){ 
    trace(&quot;每隔一秒我就会显示一次&quot;); 
} 
var sh; 
sh=setInterval(show,1000); 
clearInterval(sh); 
</pre>
<p>JS Demo:</p>
<pre class="brush: jscript; title: ; notranslate">
function auto(){ 
alert(&quot;到時間了&quot;) 
} 
var monitorInterval = null;  
function setAuto(time,isFrist){ 
    var intervalTime=time; 
        if(isFrist!=&quot;1&quot;){ 
            if(intervalTime!=&quot;off&quot;){ 
                monitorInterval= setInterval(&quot;auto()&quot;, intervalTime*1000); 
            }else{ 
            if(monitorInterval){    
                clearInterval(monitorInterval); 
                monitorInterval = null; 
            } 
        } 
    } 
} 
</pre>
<p>Html Demo:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;table&gt; 
&lt;tr&gt; 
&lt;td nowrap=&quot;nowrap&quot; bgcolor=&quot;#E8E8E8&quot;&gt;自動更新&lt;/td&gt; 
&lt;td align=&quot;left&quot; bgcolor=&quot;#E8E8E8&quot;&gt;&lt;select 
onchange=&quot;setAuto(this.value,'0')&quot;&gt; 
&lt;option value=&quot;10&quot;&gt;10sec&lt;/option&gt; 
&lt;option value=&quot;20&quot;&gt;20sec&lt;/option&gt; 
&lt;option value=&quot;30&quot;&gt;30sec&lt;/option&gt; 
&lt;option value=&quot;60&quot;&gt;1min&lt;/option&gt; 
&lt;option value=&quot;300&quot;&gt;5min&lt;/option&gt; 
&lt;option value=&quot;600&quot;&gt;10min&lt;/option&gt; 
&lt;option value=&quot;1800&quot;&gt;30min&lt;/option&gt; 
&lt;option value=&quot;3600&quot;&gt;60min&lt;/option&gt; 
&lt;option value=&quot;off&quot;&gt;Stay&lt;/option&gt; 
&lt;/select&gt;&lt;/td&gt; 
&lt;/tr&gt; 
&lt;/table&gt;
</pre>
<p>另一片文章也讲到了setInterval和clearInterval。</p>
<blockquote class="wp-embedded-content" data-secret="mxjtGy9BkW"><p><a href="https://www.mudbest.com/js%e7%ae%80%e5%8d%95%e5%ae%9e%e7%8e%b0%e6%97%b6%e9%97%b4%e6%a0%bc%e5%bc%8f%e5%80%92%e8%ae%a1%e6%97%b6/">js简单实现时间格式倒计时</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="《js简单实现时间格式倒计时》—影子" src="https://www.mudbest.com/js%e7%ae%80%e5%8d%95%e5%ae%9e%e7%8e%b0%e6%97%b6%e9%97%b4%e6%a0%bc%e5%bc%8f%e5%80%92%e8%ae%a1%e6%97%b6/embed/#?secret=mxjtGy9BkW" data-secret="mxjtGy9BkW" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Jquery倒计时插件Countdown timer jQuery Plugin</title>
		<link>https://www.mudbest.com/jquery%e5%80%92%e8%ae%a1%e6%97%b6%e6%8f%92%e4%bb%b6countdown-timer/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Wed, 09 Jan 2013 15:03:58 +0000</pubDate>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[倒计时]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1747</guid>

					<description><![CDATA[一个项目里用到了团购倒计时，本来想用递减的方式手写一个，但是想到兼容性问题，还是用封装好的Jquery插件吧。 ... <a title="Jquery倒计时插件Countdown timer jQuery Plugin" class="read-more" href="https://www.mudbest.com/jquery%e5%80%92%e8%ae%a1%e6%97%b6%e6%8f%92%e4%bb%b6countdown-timer/" aria-label="阅读 Jquery倒计时插件Countdown timer jQuery Plugin">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>一个项目里用到了团购倒计时，本来想用递减的方式手写一个，但是想到兼容性问题，还是用封装好的Jquery插件吧。<br />
今天在这里推荐的是“Countdown timer jQuery Plugin”，它是一个轻量级且灵活的倒计时插件，直接用实例说明吧。</p>
<p>首先包含主体的文件：</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script src=&quot;script/jquery.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;script/jquery.jcountdown1.3.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p><span id="more-1747"></span></p>
<p>然后在模板页面加上以下JQUERY代码</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
 
    $(&quot;#time&quot;).countdown({date:&quot;july 1, 2011&quot;}); //Just date
    $(&quot;#time&quot;).countdown({date:&quot;july 1, 2011 18:00:00&quot;}); //Date and Time (in 24 hour format)
 
    //More options
    $(&quot;#time&quot;).countdown({
        date: &quot;july 1, 2011 19:24&quot;,
        onChange: function( event, timer ){
 
            /*
            Tips:
 
            event.target is DOM Element
            this is DOM element
            $(this) is jQuery Element
            timer is interval for countdown
 
            If a countdown should end early you could do:
 
            clearInterval( timer );
            $(this).trigger('complete');
            */
 
        },
        onComplete: function( event ){
 
            $(this).html(&quot;Completed&quot;);
        },
        minus: false //defaults to false anyway
        leadingZero: true
    });
});
&lt;/script&gt;
</pre>
<p>在模板里增加一个ID。</p>
<pre class="brush: xml; title: ; notranslate">
&lt;p id=&quot;time&quot;&gt;&lt;/p&gt;
</pre>
<p>例子CSS，可忽略。</p>
<pre class="brush: css; title: ; notranslate">
p#time{
    color:#c21017;
    text-align: center;
}
p#time span{
    display:inline;
    color:#222222;
    font-size:0.8em;
}
</pre>
<p>配置里大概修改说明如下：</p>
<pre class="brush: plain; title: ; notranslate">
date: 'June 11, 2010', //Date to countdown to
 
updatetime: 1000, //Time to update timer (milliseconds)
 
//Replaces the following flags with date values
%{d} = day
%{h} = hour
%{m} = minutes
%{s} = seconds
 
//jquery.jcountdown1.3.js 主要修改在这里
htmlTemplate: &quot;%{d} &lt;span class=&quot;small&quot;&gt;days&lt;/span&gt; %{h} &lt;span class=&quot;small&quot;&gt;hours&lt;/span&gt; %{m} &lt;span class=&quot;small&quot;&gt;mins&lt;/span&gt; %{s} &lt;span class=&quot;small&quot;&gt;sec&lt;/span&gt;&quot;
 
//If countdown timer should go into minus values instead of 00:00:00:00 when countdown time has passed
minus: false
 
//Gets called each time the countdown timer updates
//Can access element with countdown timer on it, as well as the timer interval itself
onChange: function( event, timer ){}
 
//Gets called when countdown completes
onComplete: function( event ){} //Can access element with countdown timer on it
 
//Whether time should have a leading zero e.g 02 days 01 hours 09 seconds
leadingZero: falsecountdown1.3
</pre>
<p>JS时间处理部分代码一并带出：</p>
<pre class="brush: jscript; title: ; notranslate">
var date = new Date();

//时间格式替换修改
var str = '2008-10-09 21:35:28';//PHP中对应的UNIX时间戳为1223559328
var new_str = str.replace(/:/g,'-');
new_str = new_str.replace(/ /g,'-');
var arr = new_str.split(&quot;-&quot;);
var datum = new Date(Date.UTC(arr&#x5B;0],arr&#x5B;1]-1,arr&#x5B;2],arr&#x5B;3]-8,arr&#x5B;4],arr&#x5B;5]));

//转换为英文时间格式
var dt = new Date();
var m=new Array(&quot;&quot;,&quot;Jan&quot;,&quot;Feb&quot;,&quot;Mar&quot;,&quot;Apr&quot;,&quot;May&quot;,&quot;Jun&quot;,&quot;Jul&quot;,&quot;Aug&quot;,&quot;Spt&quot;,&quot;Oct&quot;,&quot;Nov&quot;,&quot;Dec&quot;);
var w=new Array(&quot;Monday&quot;,&quot;Tuseday&quot;,&quot;Wednesday&quot;,&quot;Thursday&quot;,&quot;Friday&quot;,&quot;Saturday&quot;,&quot;Sunday&quot;);
var d=new Array(&quot;st&quot;,&quot;nd&quot;,&quot;rd&quot;,&quot;th&quot;);
mn=date.getMonth();
wn=date.getDay();
dn=date.getDate();

var dns;
if(((dn%10)&lt;1) ||((dn%10)&gt;3)){
	dns=d&#x5B;3];
}else{
	dns=d&#x5B;(dn%10)-1];
	if((dn==11)||(dn==12)){
	dns=d&#x5B;3];
	}
}
document.write(&quot;&lt;hr&gt;&quot;+m&#x5B;mn]+&quot; &quot;+dn+dns+&quot; &quot; +w&#x5B;wn-1]+&quot; &quot;+dt.getFullYear()+&quot;&lt;hr&gt;&quot;);
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>js简单实现时间格式倒计时</title>
		<link>https://www.mudbest.com/js%e7%ae%80%e5%8d%95%e5%ae%9e%e7%8e%b0%e6%97%b6%e9%97%b4%e6%a0%bc%e5%bc%8f%e5%80%92%e8%ae%a1%e6%97%b6/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Tue, 13 Mar 2012 03:48:23 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[倒计时]]></category>
		<category><![CDATA[时间格式倒计时]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=913</guid>

					<description><![CDATA[在网上找了很多相关的例子，总觉得还是要根据需求来写不一样的代码，就如我只是想要实现一个时间格式的倒计时，就不需 ... <a title="js简单实现时间格式倒计时" class="read-more" href="https://www.mudbest.com/js%e7%ae%80%e5%8d%95%e5%ae%9e%e7%8e%b0%e6%97%b6%e9%97%b4%e6%a0%bc%e5%bc%8f%e5%80%92%e8%ae%a1%e6%97%b6/" aria-label="阅读 js简单实现时间格式倒计时">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>在网上找了很多相关的例子，总觉得还是要根据需求来写不一样的代码，就如我只是想要实现一个时间格式的倒计时，就不需要什么插件了，简短的一段代码即可实现。</p>
<p>看代码了：<br />
<span id="more-913"></span></p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
&lt;!--
var maxtime = 7200;//按秒计算，自己调整! by hkshadow QQ 2765237
function CountDown(){
 if(maxtime &gt;= 0){
 seconds = maxtime--;
 	//var d = parseInt(seconds/86400);
 	var h = parseInt((seconds%86400)/3600);
	var m = parseInt((seconds%3600)/60);
	var s = parseInt(seconds%60);
	
	var h = h &gt; 0 ? h : &quot;00&quot;;
	var m = m &gt; 0 ? m : &quot;00&quot;;
	var s = s &gt; 0 ? s : &quot;00&quot;;
	
 	//msg = d+&quot;天&quot;+h+&quot;小时&quot;+m+&quot;分钟&quot;+s+&quot;秒&quot;;  //倒计时
  	//msg = &quot;&quot;+h+&quot;：&quot;+m+&quot;：&quot;+s+&quot;：&quot;;  //倒计时
	//var date_array = &#x5B;h,m,s];
 	document.getElementById('hour').innerHTML=h;
 	document.getElementById('minute').innerHTML=m;
  	document.getElementById('second').innerHTML=s;
}
 else{
		clearInterval(second);
		//P.cancel();
	// top.location = &quot;/index.php&quot;;
	 }
}
setInterval(&quot;CountDown()&quot;,1000);
//--&gt;
&lt;/script&gt;
</pre>
<p>html页面代码：</p>
<pre class="brush: xml; title: ; notranslate">
&lt;span class=&quot;thespan1&quot; id=&quot;hour&quot;&gt;..&lt;/span&gt;
&lt;span class=&quot;thespan2&quot;&gt;：&lt;/span&gt;
&lt;span class=&quot;thespan1&quot; id=&quot;minute&quot;&gt;..&lt;/span&gt;
&lt;span class=&quot;thespan2&quot;&gt;：&lt;/span&gt;
&lt;span class=&quot;thespan1&quot; id=&quot;second&quot;&gt;..&lt;/span&gt;
</pre>
<p>最后的效果是<br />
1：24：50</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>js倒计时跳转</title>
		<link>https://www.mudbest.com/js%e5%80%92%e8%ae%a1%e6%97%b6%e8%b7%b3%e8%bd%ac/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 24 Feb 2011 06:38:19 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[倒计时]]></category>
		<guid isPermaLink="false">http://blog.mudbest.com/?p=417</guid>

					<description><![CDATA[&#60;script language=&#34;javascript&#34;&#62; &#60;!--  ... <a title="js倒计时跳转" class="read-more" href="https://www.mudbest.com/js%e5%80%92%e8%ae%a1%e6%97%b6%e8%b7%b3%e8%bd%ac/" aria-label="阅读 js倒计时跳转">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
&lt;script language=&quot;javascript&quot;&gt;
&lt;!--   
var maxtime = 2;//按秒计算，自己调整! by hkshadow QQ 2765237   
var hiddenid = document.getElementById('hiddenid').value;
function CountDown(){   
 if(maxtime&gt;=0){   
 seconds = maxtime--; 
 msg = seconds+&quot;秒后跳转...&quot;;   
document.getElementById('timer').innerHTML=msg;
}   
 else{   
	clearInterval(timer);   
	//P.cancel();   
 top.location = &quot;/wedding/main/bidinginfo.php?id=&quot;+hiddenid;
 }   
}   
timer = setInterval(&quot;CountDown()&quot;,1000);   
//--&gt;   
&lt;/script&gt;
</pre>
<p><span id="more-417"></span></p>
<pre class="brush: xml; title: ; notranslate">
&lt;div&gt;
&lt;input type=&quot;hidden&quot; id=&quot;hiddenid&quot; value=&quot;&lt;?php echo $result&#x5B;'aid']?&gt;&quot;  /&gt;
&lt;span style=&quot;color:#F00; line-height:45px; font-size:14px;&quot;&gt;&lt;center&gt;&lt;B&gt;恭喜您,投标成功&lt;/B&gt;&lt;/center&gt;&lt;/span&gt;.
&lt;span style=&quot;color:#F00;font-size:14px;&quot;&gt;&lt;center&gt;&lt;p id = &quot;timer&quot;&gt;3秒后跳转...&lt;/p&gt;&lt;/center&gt;&lt;/span&gt;.
&lt;span style=&quot;color:#F00;font-size:14px;&quot;&gt;&lt;center&gt;&lt;a href=&quot;#none&quot; onclick=&quot;P.cancel();&quot;/&gt;立即跳转&lt;/a&gt;&lt;/center&gt;&lt;/span&gt;.
&lt;/div&gt;
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>JS倒计时代码整理</title>
		<link>https://www.mudbest.com/js%e5%80%92%e8%ae%a1%e6%97%b6%e4%bb%a3%e7%a0%81%e6%95%b4%e7%90%86/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 23 Feb 2011 07:07:21 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[倒计时]]></category>
		<guid isPermaLink="false">http://blog.mudbest.com/?p=404</guid>

					<description><![CDATA[第一种：精确到秒的javascript倒计时代码 HTML代码: &#60;form name=&#34;fo ... <a title="JS倒计时代码整理" class="read-more" href="https://www.mudbest.com/js%e5%80%92%e8%ae%a1%e6%97%b6%e4%bb%a3%e7%a0%81%e6%95%b4%e7%90%86/" aria-label="阅读 JS倒计时代码整理">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>第一种：精确到秒的javascript倒计时代码</p>
<p>HTML代码:<span id="more-404"></span></p>
<pre class="brush: xml; title: ; notranslate">
&lt;form name=&quot;form1&quot;&gt;
&lt;div align=&quot;center&quot; align=&quot;middle&quot;&gt;
&lt;center&gt;离2012年还有:&lt;br&gt;
&lt;input type=&quot;textarea&quot; name=&quot;left&quot; size=&quot;35&quot; style=&quot;text-align: center&quot; mce_style=&quot;text-align: center&quot;&gt;
&lt;/center&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;mce:script LANGUAGE=&quot;javascript&quot;&gt;&lt;!--
startclock()
var timerID = null;
var timerRunning = false;
function showtime() {
Today = new Date();
var NowHour = Today.getHours();
var NowMinute = Today.getMinutes();
var NowMonth = Today.getMonth();
var NowDate = Today.getDate();
var NowYear = Today.getYear();
var NowSecond = Today.getSeconds();
if (NowYear &lt;2000)
NowYear=1900+NowYear;
Today = null;
Hourleft = 23 - NowHour
Minuteleft = 59 - NowMinute
Secondleft = 59 - NowSecond
Yearleft = 2009 - NowYear
Monthleft = 12 - NowMonth - 1
Dateleft = 31 - NowDate
if (Secondleft&lt;0)
{
Secondleft=60+Secondleft;
Minuteleft=Minuteleft-1;
}
if (Minuteleft&lt;0)
{ 
Minuteleft=60+Minuteleft;
Hourleft=Hourleft-1;
}
if (Hourleft&lt;0)
{
Hourleft=24+Hourleft;
Dateleft=Dateleft-1;
}
if (Dateleft&lt;0)
{
Dateleft=31+Dateleft;
Monthleft=Monthleft-1;
}
if (Monthleft&lt;0)
{
Monthleft=12+Monthleft;
Yearleft=Yearleft-1;
}
Temp=Yearleft+'年, '+Monthleft+'月, '+Dateleft+'天, '+Hourleft+'小时, '+Minuteleft+'分, '+Secondleft+'秒'
document.form1.left.value=Temp;
timerID = setTimeout(&quot;showtime()&quot;,1000);
timerRunning = true;
}
var timerID = null;
var timerRunning = false;
function stopclock () {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock () {
stopclock();
showtime();
}
// --&gt;&lt;/mce:script&gt;
</pre>
<p>第二种：某某运动会<br />
HTML代码：</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!--倒计时Javascript begin--&gt;

 &lt;mce:script language=&quot;JavaScript&quot;&gt;&lt;!--
 
 function DigitalTime1()
 { 
 var deadline= new Date(&quot;08/13/2007&quot;) //开幕倒计时
 var symbol=&quot;8月13日&quot;
 var now = new Date()
 var diff = -480 - now.getTimezoneOffset() //是北京时间和当地时间的时间差
 var leave = (deadline.getTime() - now.getTime()) + diff*60000
 var day = Math.floor(leave / (1000 * 60 * 60 * 24))
 var hour = Math.floor(leave / (1000*3600)) - (day * 24)
 var minute = Math.floor(leave / (1000*60)) - (day * 24 *60) - (hour * 60)
 var second = Math.floor(leave / (1000)) - (day * 24 *60*60) - (hour * 60 * 60) - (minute*60)

 var deadline_2= new Date(&quot;08/13/2004&quot;) //开幕后计时
 var symbol_2=&quot;8月13日&quot;
 var now_2 = new Date()
 var diff_2 = -480 - now.getTimezoneOffset() //是北京时间和当地时间的时间差
 var leave_2 = (now_2.getTime() - deadline_2.getTime()) + diff_2*60000
 var day_2 = Math.floor(leave_2 / (1000 * 60 * 60 * 24))
 var hour_2 = Math.floor(leave_2 / (1000*3600)) - (day_2 * 24)
 var minute_2 = Math.floor(leave_2 / (1000*60)) - (day_2 * 24 *60) - (hour_2 * 60)
 var second_2 = Math.floor(leave_2 / (1000)) - (day_2 * 24 *60*60) - (hour_2 * 60 * 60) - (minute_2*60)
 
 day=day+1;
 day_2=day_2+1;

 if (day&gt;0) //还未开幕
 {
 //LiveClock1.innerHTML = &quot;现在&quot;+symbol+&quot;天&quot;
 LiveClock1.innerHTML = &quot;&lt;font class=fon1&gt;距离&quot;+symbol+&quot;开幕还有&lt;font class=fon2&gt;&quot;+day+&quot;&lt;/font&gt;天&lt;/font&gt;&quot;
 setTimeout(&quot;DigitalTime1()&quot;,1000)
 }

 if (day&lt;0) //已经开幕
 {
 //LiveClock1.innerHTML = &quot;现在离&quot;+symbol+&quot;还有&quot;+day+&quot;天&quot;+hour+&quot;小时&quot;+minute+&quot;分&quot;+second +&quot;秒&quot;
 LiveClock1.innerHTML = &quot;&lt;font class=fon1&gt;&quot;+symbol+&quot;开幕已有&lt;font class=fon2&gt;&quot;+day_2+&quot;&lt;/font&gt;天&lt;/font&gt;&quot;
 setTimeout(&quot;DigitalTime1()&quot;,1000)

 }

 if (day==0) //正在开幕
 {
 //LiveClock1.innerHTML = &quot;现在&quot;+symbol+&quot;天&quot;
 LiveClock1.innerHTML = &quot;&lt;font class=fon1&gt;某某运动会今天开幕&lt;/font&gt;&quot;
 setTimeout(&quot;DigitalTime1()&quot;,1000)
 }
 
 if (day&lt;0 &amp; day_2&gt;19) //某某运动会结束
 {
 //LiveClock1.innerHTML = &quot;现在离&quot;+symbol+&quot;还有&quot;+day+&quot;天&quot;+hour+&quot;小时&quot;+minute+&quot;分&quot;+second +&quot;秒&quot;
 LiveClock1.innerHTML = &quot;&lt;font class=fon1&gt;某某运动会已全部结束&lt;/font&gt;&quot;
 setTimeout(&quot;DigitalTime1()&quot;,1000)

 }

 }
// --&gt;&lt;/mce:script&gt;
 &lt;!--倒计时Javascript end--&gt;
&lt;body onload=DigitalTime1()&gt;
&lt;div id= LiveClock1&gt;&lt;/div&gt;
&lt;/body&gt;
</pre>
<p>第三种：小时倒计时<br />
HTML代码:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;
&lt;!--
var maxtime = 60*60 //一个小时，按秒计算，自己调整!
function CountDown(){
 if(maxtime&gt;=0){
 minutes = Math.floor(maxtime/60);
 seconds = Math.floor(maxtime%60);
 msg = &quot;距离结束还有&quot;+minutes+&quot;分&quot;+seconds+&quot;秒&quot;;
 document.getElementById('timer').innerHTML=msg;
 if(maxtime == 5*60) alert('注意，还有5分钟!');
 --maxtime;
 }
 else{
 clearInterval(timer);
 alert(&quot;时间到，结束!&quot;);
 }
}
timer = setInterval(&quot;CountDown()&quot;,1000);
//--&gt;
&lt;/SCRIPT&gt;

&lt;div id=&quot;timer&quot; style=&quot;color:red&quot; mce_style=&quot;color:red&quot;&gt;&lt;/div&gt;
</pre>
<p>第四种：最简倒计时<br />
代码:</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;Script Language=&quot;JavaScript&quot;&gt; 
&lt;!-- Begin 
　　var timedate= new Date(&quot;January 14,2006&quot;); 
　　var times=&quot;研究生考试&quot;; 
　　var now = new Date(); 
　　var date = timedate.getTime() - now.getTime(); 
　　var time = Math.floor(date / (1000 * 60 * 60 * 24)); 
　　if (time &gt;= 0) ;
document.write(&quot;&lt;li&gt;&lt;font color=#DEDBDE&gt;现在离2006年&quot;+times+&quot;还有: &lt;font color=#ffffff&gt;&lt;b&gt;&quot;+time +&quot;&lt;/b&gt;&lt;/font&gt; 天&lt;/font&gt;&lt;/li&gt;&quot;);
// End --&gt;
&lt;/Script&gt;
</pre>
<p>第五种：最简倒计时二</p>
<p>HTML代码:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;mce:script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;&gt;&lt;!--
function djs(){
var urodz= new Date(&quot;11/12/2008&quot;);　
var now = new Date();
var num
var ile = urodz.getTime() - now.getTime();　　
var dni = Math.floor(ile / (1000 * 60 * 60 * 24));　　
if (dni &gt;1)　　
num=dni+1
else if (dni == 1)　num=2　
else if (dni == 0)　num=1
else num=0　
document.write(num)　　
}
// --&gt;&lt;/mce:script&gt;

距某某开幕式还有 &#x5B;&lt;mce:script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;&gt;&lt;!--
djs()
// --&gt;&lt;/mce:script&gt;] 天
</pre>
<p>第六种：Javascript倒计时器 &#8211; 采用系统时间自校验</p>
<pre class="brush: xml; title: ; notranslate">
这次利用系统时间自校验倒计时, 无需手工调校使得倒计时更为精确, 代码及详细注释如下:

&lt;span id=&quot;clock&quot;&gt;00:01:11:00&lt;/span&gt;
&lt;input id=&quot;startB&quot; type=&quot;button&quot; value=&quot;start countdown!&quot; onclick=&quot;run()&quot;&gt;
&lt;input id=&quot;endB&quot; type=&quot;button&quot; value=&quot;stop countdown!&quot; onclick=&quot;stop()&quot;&gt;
&lt;br&gt;
&lt;input id=&quot;diff&quot; type=&quot;text&quot;&gt;
&lt;input id=&quot;next&quot; type=&quot;text&quot;&gt;
&lt;mce:script language=&quot;Javascript&quot;&gt;&lt;!--
/* This notice must be untouched at all times.

countdown.js    v. 1.0
The latest version is available at
http://blog.csdn.net/yjgx007

Copyright (c) 2004 Xinyi.Chen. All rights reserved.
Created 7/30/2004 by Xinyi.Chen. 
Web: http://blog.csdn.net/yjgx007
E-Mail: chenxinyi1978@hotmail.com
Last modified: 7/30/2004

This program is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;

See the GNU General Public License
at http://www.gnu.org/copyleft/gpl.html for more details.
*/
var normalelapse = 100;
var nextelapse = normalelapse;
var counter; 
var startTime;
var start = clock.innerText; 
var finish = &quot;00:00:00:00&quot;;
var timer = null;

// 开始运行
function run() {
  startB.disabled = true;
  endB.disabled = false;
  counter = 0;
  // 初始化开始时间
  startTime = new Date().valueOf();

  // nextelapse是定时时间, 初始时为100毫秒
  // 注意setInterval函数: 时间逝去nextelapse(毫秒)后, onTimer才开始执行
  timer = window.setInterval(&quot;onTimer()&quot;, nextelapse); 
}

// 停止运行
function stop() {
  startB.disabled = false;
  endB.disabled = true;
  window.clearTimeout(timer);
}

window.onload = function() {
  endB.disabled = true;
}

// 倒计时函数
function onTimer()
{

if (start == finish)
{
  window.clearInterval(timer);
  alert(&quot;time is up!&quot;);
  return;
}

var hms = new String(start).split(&quot;:&quot;);
var ms = new Number(hms&#x5B;3]);
var s = new Number(hms&#x5B;2]);
var m = new Number(hms&#x5B;1]);
var h = new Number(hms&#x5B;0]);
  
ms -= 10;
if (ms &lt; 0)
{
  ms = 90;
  s -= 1;
  if (s &lt; 0)
  {
    s = 59;
    m -= 1;
  }
  
  if (m &lt; 0)
  {
    m = 59;
    h -= 1;
  }
}

var ms = ms &lt; 10 ? (&quot;0&quot; + ms) : ms;
var ss = s &lt; 10 ? (&quot;0&quot; + s) : s;
var sm = m &lt; 10 ? (&quot;0&quot; + m) : m;
var sh = h &lt; 10 ? (&quot;0&quot; + h) : h;

start = sh + &quot;:&quot; + sm + &quot;:&quot; + ss + &quot;:&quot; + ms;
clock.innerText = start;

// 清除上一次的定时器
window.clearInterval(timer);

// 自校验系统时间得到时间差, 并由此得到下次所启动的新定时器的时间nextelapse
counter++; 
var counterSecs = counter * 100;
var elapseSecs = new Date().valueOf() - startTime;
var diffSecs = counterSecs - elapseSecs;
nextelapse = normalelapse + diffSecs;
diff.value = counterSecs + &quot;-&quot; + elapseSecs + &quot;=&quot; + diffSecs;
next.value = &quot;nextelapse = &quot; + nextelapse;
if (nextelapse &lt; 0) nextelapse = 0;

// 启动新的定时器
timer = window.setInterval(&quot;onTimer()&quot;, nextelapse); 
}
// --&gt;&lt;/mce:script&gt;
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
