00:00:00样式的倒计时设计? 全数位的倒计时设计:01:30:00 ---> 00:00:01 请赐教!谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html> <head> <meta http-equiv="content-type" content="text/html;charset=gb2312" /> <title>记时器</title> <script src="timer.js" type="text/javascript"></script> </head> <body><div id="div1"></div><div id="div2"></div><div id="div3"></div><script type="text/javascript">//==========生成记时器,注意生成实例要在你的对象下面,要不会提示“请设置要显示时间的对象!”的错误new Timer(1,30,0,"div1")new Timer(0,2,0,"div2")new Timer(0,0,30,"div3")</script></body></html>/* timer.js ---Edit By ShowBo*///===========辅助函数function FormatNumber(Num){if(Num<10)return "0"+Num;else return Num.toString();}function $(Id){if(typeof(Id)=="string")return document.getElementById(Id);else return Id;}//===========function Timer(hour,minute,second,ObjId){ var PackUp=this; this.hour=hour; this.minute=minute; this.second=second; this.obj=$(ObjId); if(!this.obj) { alert("请设置要显示时间的对象!") return; } this.obj.innerHTML=FormatNumber(this.hour)+":"+FormatNumber(this.minute)+":"+FormatNumber(this.second); if(hour<1&&minute<1&&second<1) { alert("此记时器无效!"); return; } this.Go=function() { if(this.hour<1&&this.minute<1&&this.second<1) { clearInterval(this.timer); this.timer=null; alert(ObjId+"记时完成!"); return; } this.second--; if(this.second<1) { if(this.minute>0) { this.second=59; this.minute--; } else if(this.hour>0) { this.minute=59; this.hour--; } } this.obj.innerHTML=FormatNumber(this.hour)+":"+FormatNumber(this.minute)+":"+FormatNumber(this.second); } this.timer=setInterval(function(){PackUp.Go();},1000); } http://topic.csdn.net/u/20080526/16/67d993af-5c8f-4767-b9fb-1a47df2d0174.html?seed=237871488 <!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=gb2312" /> <title>无标题文档 </title> <script type="text/JavaScript"> var lastMinutes=59; var lastSeconds=60; var t,stingTime; function showTime(){ document.getElementById("hehe").disabled=true; var allTime=60*60*1000; lastSeconds--; if(lastSeconds==0 && lastMinutes==0){ clearTimeout(t); return; }else if(lastSeconds<0){ lastSeconds=59; lastMinutes--; } stringTime="还剩时间为:"+lastMinutes+" : "+lastSeconds; document.getElementById("timeDiv").innerHTML=stringTime; setTimeout(showTime,1000);}</script> </head> <body> <input type='button' value='开始考试' onclick='showTime();' id='hehe'><div id='timeDiv'></div> </body> </html> http://download.csdn.net/source/322576#acomment这里有我写过的计时器的程序,是个自动关机程序。大家用用看看,C++写的。不过源代码格掉了,这个也是当初考给我弟弟用的,才得以保留下来。是我写的第一个图形化程序. 其中计时器,没用到任何现成函数,是定义了h,m,s等变量来实现计时的,小时h我只定了了最大不能超过24。 另外还有一个问题,就是这个程序调定了时间什后,不能按回车否则跳掉,只能用鼠标点。这是当初没有定义的问题。后才才想起。 如何在JAVASCRIPT中修改HTTP登录的密码 关于json对象转换的问题 求正则验证 图片放大层显示效果。 如何将 activeX 中的某个值传递给 web 页面的中的一个输入框呢? 在线等! 怎样传递数组? 5个图片,随机显示其中3个,该怎么做。要求用纯js实现。马上结帐。谢谢各位 急救(怎样在talbe的单元格中划斜线) javascript问题:解决给100分加贴100分,在线等待 高手请进,90分相送! 散分了~一不小心CSDN改版了? ie7 不支持scrollHeight 怎么解决?
<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<title>记时器</title>
<script src="timer.js" type="text/javascript"></script>
</head>
<body>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<script type="text/javascript">
//==========生成记时器,注意生成实例要在你的对象下面,要不会提示“请设置要显示时间的对象!”的错误
new Timer(1,30,0,"div1")
new Timer(0,2,0,"div2")
new Timer(0,0,30,"div3")
</script>
</body>
</html>/*
timer.js
---Edit By ShowBo
*/
//===========辅助函数
function FormatNumber(Num){if(Num<10)return "0"+Num;else return Num.toString();}
function $(Id){if(typeof(Id)=="string")return document.getElementById(Id);else return Id;}
//===========
function Timer(hour,minute,second,ObjId)
{
var PackUp=this;
this.hour=hour;
this.minute=minute;
this.second=second;
this.obj=$(ObjId);
if(!this.obj)
{
alert("请设置要显示时间的对象!")
return;
}
this.obj.innerHTML=FormatNumber(this.hour)+":"+FormatNumber(this.minute)+":"+FormatNumber(this.second);
if(hour<1&&minute<1&&second<1)
{
alert("此记时器无效!");
return;
}
this.Go=function()
{
if(this.hour<1&&this.minute<1&&this.second<1)
{
clearInterval(this.timer);
this.timer=null;
alert(ObjId+"记时完成!");
return;
}
this.second--;
if(this.second<1)
{
if(this.minute>0)
{
this.second=59;
this.minute--;
}
else if(this.hour>0)
{
this.minute=59;
this.hour--;
}
}
this.obj.innerHTML=FormatNumber(this.hour)+":"+FormatNumber(this.minute)+":"+FormatNumber(this.second);
}
this.timer=setInterval(function(){PackUp.Go();},1000);
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
<script type="text/JavaScript">
var lastMinutes=59;
var lastSeconds=60;
var t,stingTime;
function showTime(){
document.getElementById("hehe").disabled=true;
var allTime=60*60*1000;
lastSeconds--;
if(lastSeconds==0 && lastMinutes==0){
clearTimeout(t);
return;
}
else if(lastSeconds<0){
lastSeconds=59;
lastMinutes--;
}
stringTime="还剩时间为:"+lastMinutes+" : "+lastSeconds;
document.getElementById("timeDiv").innerHTML=stringTime;
setTimeout(showTime,1000);
}
</script> </head>
<body>
<input type='button' value='开始考试' onclick='showTime();' id='hehe'>
<div id='timeDiv'></div>
</body> </html>
这里有我写过的计时器的程序,是个自动关机程序。大家用用看看,C++写的。不过源代码格掉了,这个也是当初考给我弟弟用的,才得以保留下来。是我写的第一个图形化程序. 其中计时器,没用到任何现成函数,是定义了h,m,s等变量来实现计时的,小时h我只定了了最大不能超过24。 另外还有一个问题,就是这个程序调定了时间什后,不能按回车否则跳掉,只能用鼠标点。这是当初没有定义的问题。后才才想起。