亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

js判斷60秒以及倒計(jì)時(shí)示例代碼

 更新時(shí)間:2014年01月24日 08:51:00   作者:  
本篇文章主要是對(duì)js判斷60秒以及倒計(jì)時(shí)的示例代碼進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助

用js判斷60秒到計(jì)時(shí),首先定義一個(gè)變量refreshTime,當(dāng)觸發(fā)事件的時(shí)候檢查一下上一次請(qǐng)求成功的時(shí)間距離現(xiàn)在是否超過(guò)60秒,如果沒(méi)有超過(guò)60秒,則彈出提示,

否則則允許繼續(xù)請(qǐng)求,請(qǐng)求成功之后,把當(dāng)前的時(shí)間賦值給refreshTime,具體實(shí)現(xiàn)方式;

復(fù)制代碼 代碼如下:

usingNamespace("Biz.AccountCenter")["CellPhoneValidation"]={ 
    refreshTime:0, //變量

    checkRefreshGet:function(timeLimit) //檢查時(shí)間,timelimit為傳入請(qǐng)求需要間隔的時(shí)間(單位秒),比如:60
    {
      var nowTime = new Date();
      var nowMinitePoint=nowTime.getHours()*3600+nowTime.getMinutes()*60+nowTime.getSeconds();

     if(nowMinitePoint-Biz.AccountCenter.CellPhoneValidation.refreshTime<timeLimit )
     {
         return false;
     }
         return true;
    },

    resetRefreshGet:function() //請(qǐng)求成功之后,調(diào)用的方法,把定義的變量重置為當(dāng)前時(shí)間
    {
       var nowTime = new Date();
       var nowMinitePoint=nowTime.getHours()*3600+nowTime.getMinutes()*60+nowTime.getSeconds();
       Biz.AccountCenter.CellPhoneValidation.refreshTime=nowMinitePoint;
    },

&nbsp;dynamicMessage:function(timeSecond) //倒計(jì)時(shí)方法 timeSecond為從多少秒開(kāi)始,比如:60
    {
       var showTimmer;
       if (showTimmer) {
           clearTimeout(showTimmer);
       }

       if(timeSecond==dynamicValidate.refreshTimeLimit)
       {
            var messageRefresh =$.newegg.format(dynamicValidate.refreshSpanMessage,timeSecond);
           $("#spanRefresh").html("<span>"+messageRefresh+"</span>");
            $("#spanRefresh").attr("class","button btn_yanz_disable");
           timeSecond--;
       }

       showTimmer = setTimeout(function () {
           var messageRefresh =$.newegg.format(dynamicValidate.refreshSpanMessage,timeSecond);
           $("#spanRefresh").html("<span>"+messageRefresh+"</span>");
           timeSecond--;
           if (timeSecond < 0) {
               clearTimeout(showTimmer);
               $("#spanRefresh").attr("class","button btn_yanz");
               $("#spanRefresh").html("<span>"+dynamicValidate.refreshMessage+"</span>");
           } else {
               Biz.AccountCenter.CellPhoneValidation.dynamicMessage(timeSecond);
                $("#spanRefresh").attr("class","button btn_yanz_disable");
           }
       }, 1000);
    },

   &nbsp;create: function(obj,page,isCancelPhone) //每次請(qǐng)求調(diào)用的方法
&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!Biz.AccountCenter.CellPhoneValidation.checkRefreshGet(dynamicValidate.refreshTimeLimit)) //每次請(qǐng)求的時(shí)候,js檢查60s時(shí)間間隔
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#valiateerror").empty().html("<span class='Validform_wrong'>"+$.newegg.format($Resource.BuildContent("AccountCenter_ModifyDyanmic_CanNotRepeatClick"),dynamicValidate.refreshTimeLimit)+"</span>").show();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#mobilewarning").hide();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

       $.get("url",data,function(){

             //如果成功
             Biz.AccountCenter.CellPhoneValidation.dynamicMessage(dynamicValidate.refreshTimeLimit);//倒計(jì)時(shí)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Biz.AccountCenter.CellPhoneValidation.resetRefreshGet();//重置時(shí)間
       });
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    }
&nbsp;}

相關(guān)文章

最新評(píng)論