js倒计时 如何加 毫秒

taokai 2009-12-17 09:01:41
请问这段js倒计时 如何加 毫秒,

当 var TotalMilliSeconds = 9*500*1000这里的时间倒计完了,就直接写结束,如何做/

<script language="JavaScript">
var TotalMinutes = 5;
var TotalMilliSeconds = 1*10*1000;//分,时,秒,

function takeCount()
{
//计数减一
TotalMilliSeconds -= 1000;
//计算时分秒
var hours = Math.floor( TotalMilliSeconds / ( 1000 * 60 * 60 )) % 24;
var minutes = Math.floor(TotalMilliSeconds / (1000 * 60)) % 60;
var seconds = Math.floor(TotalMilliSeconds / 1000) % 60;

//将时分秒插入到html中
document.getElementById("RemainH").innerHTML = hours;
document.getElementById("RemainM").innerHTML = minutes;
document.getElementById("RemainS").innerHTML = seconds;

}

window.onload = setInterval("takeCount();",1000);
</script>

<div id="CountMsg">
倒计时还有:
<strong id="RemainD"></strong><strong id="RemainH">XX</strong>时
<strong id="RemainM">XX</strong>分
<strong id="RemainS">XX</strong>秒
</div>
...全文
277 2 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
boss5518831534_ 2010-09-19
  • 打赏
  • 举报
回复
学习一下
jol_boy 2009-12-17
  • 打赏
  • 举报
回复
给你一个~~

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script language="javascript">
function countdown(endtime, today)
{
today = new Date();
target_time=new Date(endtime);
timeold=(target_time.getTime()-today.getTime());
sectimeold=timeold/1000;
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000;
e_daysold=timeold/msPerDay;
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor(e_minsold);
e_seconds=(e_minsold-minsold)*60;
seconds=Math.floor(e_seconds);
e_millisecond=(e_seconds-seconds)*1000;
millisecond=Math.floor(e_millisecond);
millisecond10=Math.floor(millisecond);

the_element = document.getElementById('counttime');
the_element.innerHTML="仅剩 "+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒"+millisecond10/*+"毫秒"*/ ;

window.setTimeout("countdown('" + endtime + "', today)", 100);
}
</script>


<BODY>
<table><tr><td width="175"><SPAN id="counttime" style="FONT-WEIGHT: bold; COLOR: #000000; FONT-FAMILY:Arial"></SPAN>
<script language="javascript">
var endtime = '3-20-2008 00:00:00';
var today = new Date();
countdown(endtime, today);
</script></td></tr></table>
</BODY>
</HTML>

发帖
JavaScript

8.7w+

社区成员

Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
帖子事件
创建了帖子
2009-12-17 09:01
社区公告
暂无公告