当前位置:编程学习 > C#/ASP.NET >>

跪求,.net时间倒计时 以分钟为单位 急急急~!!

急急急,跪求啊!!!
我是用vs 2005开发的网上考试系统,在设计时间倒计时的时候函数是以秒为单位的,而且走得很快,有谁能帮下忙,真急啊,后天就要答辩了!!!!我那个函数的代码是
function sessionTimeout() 

var label=document.getElementById("lblTime"); 
var seconds=parseInt(label.value); 
seconds=seconds-1; 
label.value=seconds.toString(); 
if(seconds==0) 

alert("请在规定时间内提交您的试卷否则没有成绩!!谢谢合作"); 
//window.location.href="login.aspx";//转到登陆页 
document.all.imgBtnSubmit.click(); 


clearInterval(sessionTimeout); 

--------------------编程问答-------------------- setTimeout(fun, 60 * 1000); --------------------编程问答--------------------

<script language="javascript" type="text/javascript">   
//倒计时(显示分、秒,按半小时计时) 
var currentHour     =   <%=System.DateTime.Now.ToString("HH") %>;   //当前的小时
var currentMinute   =   <%=System.DateTime.Now.ToString("mm") %>;   //当前的分钟
var currentSecond   =   <%=System.DateTime.Now.ToString("ss") %>;   //当前的秒
var seconds         =   currentSecond;  //当前的秒
var beforeHalfHours =   0;              // 是否为半点以前(<30分钟) 0:前半小时; 1:后半小时


var residuarySecond;        //剩余的总秒数

setResiduarySenond();       //计算剩余的总秒数

function CountDown(){ 
  //按半小时计时
    if(residuarySecond>0){
    
        var minutes = Math.floor(residuarySecond / 60);   //剩余分钟
        var seconds = Math.floor(residuarySecond % 60);   //剩余的秒
        
        //
        // 显示在界面上
        //
        if(seconds<10)
        {
            document.getElementById("timesec").innerHTML="0"+seconds;
        }
        else
        {
            document.getElementById("timesec").innerHTML=seconds; 
        }

        if(minutes<10)
        {
            document.getElementById("timemin").innerHTML="0"+minutes;
        }
        else
        { 
            document.getElementById("timemin").innerHTML=minutes;   
        } 
        
        //
        // 剩余秒减1
        //
         --residuarySecond;
     }
     else
     {
        //
        // 如果为半点结束,设置标记进入后半点
        // 如果为整点结束,则增加一个小时,并设置标记为<30进入前半点
        //
        
        if (beforeHalfHours == 0)
        {
            //
            // 半点结束
            //
            beforeHalfHours = 1;
        }
        else
        {
        
            //
            // 整点结束
            //
            beforeHalfHours = 0;
            
            currentHour++;      //小时+1
            
        }
                
        //
        //活动每日截至时间为17:00
        //
        if (currentHour>=17)
        {
            //
            // 停止计时
            //
            clearInterval(timer);
            
            return;
        }
        else
        {
            //
            // 计算剩余的总秒数
            //
            currentMinute=0;
            currentSecond=1;
            
            setResiduarySenond();
            
            //
            // 立即执行一次,防止出现空余一秒的情况
            //
            CountDown();
        }
     }   
}

//
// 计算剩余的总秒数
//
function setResiduarySenond()
{
    if(currentMinute>=30)  
        residuarySecond = (60-currentMinute)*60 ;     
    else
        residuarySecond = (30-currentMinute)*60 ; 
        
    residuarySecond = residuarySecond - currentSecond;
}

function start()
{
    //
    // 活动时间为 8:00 ~ 17:00
    //
    if (currentHour < 8 ||
        currentHour > 17)
    {
        return;
    }
        
    //
    // 设置当前时间是前半点或后半点
    //
    if (currentMinute < 30)
        beforeHalfHours = 0;
    else
        beforeHalfHours = 1;
        
    timer =  setInterval("CountDown()",1000);
}

//start();

alert('本期秒杀活动已结束,感谢您的支持!');
</script> 



这是我们做秒杀的代码,分钟,秒 --------------------编程问答-------------------- 看楼主能不能用的上,呵呵 --------------------编程问答-------------------- 路过
看见跪着的,就不舒服
这年头呀
--------------------编程问答-------------------- var total=2*3600;//总共多少秒
function showTime()

total--;
var hour=total/3600;
var sec=(total%3600)/60;
var min=(total%3600)%60;
document.getElementById("divId").innerHTML="还有"+hour+"小时"+sec+"分"+min+"秒";
 if(total>0)
 {
 setTimeout("showTime()",2000);
}
else
{document.all.imgBtnSubmit.click();  
  }
}
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AlwaysVisibleControl/AlwaysVisibleControl.aspx --------------------编程问答-------------------- c#时间倒计时 

http://www.cnblogs.com/1848/articles/1528858.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=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
<!--
 //获得当前时间,刻度为一千分一秒 
var initializationTime=(new Date()).getTime(); 
function showLeftTime()
{
 var now=new Date();
 var year=now.getYear();
 var month=now.getMonth();
 var day=now.getDate();
 var hours=now.getHours();
 var minutes=now.getMinutes();
 var seconds=now.getSeconds();
 document.all.show.innerHTML="当前时间:"+year+"年"+month+"月"+day+"日"+hours+"小时"+minutes+"分";
 //设定结束时间
 //1秒=1000毫秒
 endTime=initializationTime+60000;
 //设定并显示剩余时间

 var leftTime=endTime-(new Date()).getTime();
 if(leftTime>0)
 {
  document.all.showLeft.innerHTML=leftTime+"微秒后停止!";
 }
 else
 { 
  clearTimeout(timeID);
  document.all.showLeft.innerHTML="TimeOut!";
  return false;
 }
 //一秒刷新一次显示时间 
 var timeID=setTimeout(showLeftTime,1000); 
}
//-->
</script>
</head>
<body onload="showLeftTime()">
<label id="show">这里显示开始时间</label><br>
<label id="showLeft">这里显示剩余时间</label>
</body>
</html>
--------------------编程问答-------------------- ... --------------------编程问答-------------------- 留名学习 --------------------编程问答-------------------- 哭~~ 还是改不来唉。。怎么改才能让他变为以分钟为单位呢? 现在是以秒为单位,而且时间走得超快的,根本就不是一秒。上面那些代码都太长了额。可不可以在我那代码额基础上改呢? 谢谢各位啦!! --------------------编程问答-------------------- 进来学习学习! --------------------编程问答--------------------

<!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>

 <BODY>
  <SCRIPT LANGUAGE="JavaScript">
/////////////////////////////////////
//////自定义定时器 V1.0
//////sun.Lei 2009
//////参数说明new CustomTimer([值],[类型(分钟:"m",秒:"s")],[定时器走动时,所触发的事件],[定时器运行完毕后所触发的事件])
/////////////////////////////////////

/////开始//////////////
var Class = {
   create: function() {
  return function() { this.init.apply(this, arguments); }
   }
}

var Bind = function(object, func) {
return function() {
return func.apply(object, arguments);
}
}

var CustomTimer=Class.create();
CustomTimer.prototype={
init : function(value , timeType , refRunMethod , refStopMethod){
this.Value=value;
this.TimeType=timeType;
this.StopMethod=refStopMethod;
this.RunMethod=refRunMethod;
this.RefRun=Bind(this,this.Run);
this.Statu="Stop";
this.Times;
this.NewTime;
this.Timer=null;
},

ReSet: function(){
this.NewTime=new Date(2009,1,1,0,0,0);
this.Times={h:"00",m:"00",s:"00"};
if(this.TimeType=="s"){
this.NewTime.setSeconds(this.Value);
}
else{
this.NewTime.setMinutes(this.Value);
}
},

Stop: function(){
clearInterval(this.Timer);
this.Timer=null;
this.Statu="Stop";
},

Start:function(){
if(this.Statu=="Stop"){
this.ReSet();
}

this.Statu="Start";
if(this.Timer==null){
this.Timer=setInterval(this.RefRun,1000);
}

},

Run:function(){
if(this.Statu!="Start"){
return;
}

this.NewTime.setMilliseconds(-1);
var h=this.NewTime.getHours();
var m=this.NewTime.getMinutes();
var s=this.NewTime.getSeconds();
this.Times.h=h<10?"0"+h:h;
this.Times.m=m<10?"0"+m:m;
this.Times.s=s<10?"0"+s:s;
if(typeof(this.RunMethod)=="function"){
this.RunMethod(this.Times);
}

if(h==0 && m==0 && s==0 && typeof(this.StopMethod)=="function"){
this.Stop();
this.StopMethod();
}
},

Pause:function(){
this.Statu="Pause";
},

GetCurrentTime:function(){
return this.Times;
}
}
/////结束/////////




/////////以下为调用例子,请自已缩减以下方法.
var obj1,obj2,obj3

function start1(){
var v=document.form1.n1.value;
if(obj1==null){

obj1=new CustomTimer(parseInt(v),"s",runmethod1,stopmethod1);
}
if(obj1.Statu=="Start" ){
alert('正在运行中...');
return;
}
obj1.Value=parseInt(v);
obj1.Start();
}

function start2(){
var v=document.form1.n2.value;
if(obj2==null){

obj2=new CustomTimer(parseInt(v),"m",runmethod2,stopmethod2);
}
if(obj2.Statu=="Start" ){
alert('正在运行中...');
return;
}
obj2.Value=parseInt(v);
obj2.Start();
}

function pause(obj , o){

if(obj != null){
if(obj.Statu == "Pause"){
obj.Start();
o.value = "暂停";
return;
}

if(obj.Statu == "Start"){
obj.Pause();
o.value = "继续";
return;
}

}

}

function runmethod1(o){
document.getElementById("case1").innerHTML=o.h+" : "+o.m+" : "+o.s;
}
function stopmethod1(){
document.getElementById("case1").innerHTML="GAME OVER!!";
}

function runmethod2(o){
document.getElementById("case2").innerHTML=o.h+" : "+o.m+" : "+o.s;
}
function stopmethod2(){
document.getElementById("case2").innerHTML="GAME OVER!!";
}
function t(o){
if(o==null)return;
o=o.GetCurrentTime();
alert('计时器当前时间: '+o.h+":"+o.m+":"+o.s);
}

  </SCRIPT>
<form name="form1">
  <input type="text" name="n1" value="10"/> 秒 <input type="button" value="启动倒计时" onclick="start1()" />  <input type="button" value="暂停" onclick="pause(obj1,this)" /> <input type="button" value="现在时间到哪了" onclick="t(obj1)" />  <input type="button" value="重置并停止" onclick="if(obj1!=null){obj1.ReSet();obj1.Stop()}" /> <span id="case1" style="font-size:32px;font-family:微软雅黑;color:red"></span> <br/>
 
 <input type="text" name="n2" value="1" /> 分钟 <input type="button" value="启动倒计时" onclick="start2()" /> <input type="button" value="暂停" onclick="pause(obj2,this)" />  <input type="button" value="现在时间到哪了" onclick="t(obj2)" />  <input type="button" value="重置并停止" onclick="if(obj2!=null){obj2.ReSet();obj2.Stop();}" /><span id="case2" style="font-size:32px;font-family:微软雅黑;color:red"></span> <br/>



</form>
 </BODY>
</HTML>

希望对你有用 --------------------编程问答-------------------- 帮顶~ --------------------编程问答-------------------- 看你的结贴律。。还有你的跪求。。还有你调程序的能力。。我真想劝你自己多动脑子。。代码不是人教的。。别人只会给你个思路。。还是要靠自己去琢磨。。 --------------------编程问答-------------------- http://download.csdn.net/source/1686988

带css样式的倒计时器 (JavaScript实现) --------------------编程问答-------------------- 学习了!!
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,