No nonsense directly on the code
1<script language= "JavaScript" >2 //Countdown3 varInterval = 1000;4 varNowserver =NewDate (' @DateTime. now.tostring () ');//Server Time5 varnow =NewDate ();//Client Time6 varDateDiff = Nowserver.gettime ()-now.gettime ();//server-client Time Difference7 //alert (DATEDIFF);8 9 varEndDate =NewDate (' @DateTime. Now.addminutes (10). ToString () ');//Don't move note here @datetime.now.addminutes (10). ToString () is a. NET codeTen One //method of Resend A //function payverify () { - //$.post ('/retailsales/payverify ', {orderno: "@Model. OrderNumber", OrderID: "@Model. Ordersid", Paypwd: $ (' #paypwd '). Val ()}, function (data) { - //$ (' #buttompay '). HTML (data); the // - // }); - // } - + functionShowcountdown (divname) { -now =NewDate ();//client time, it's a recurring change. + varLefttime = Enddate.gettime ()-now.gettime () + DateDiff;//Fix Time difference A varCC =document.getElementById (divname); at if(Lefttime > 0) { - varLeftsecond = parseint (lefttime/1000); - varDay1 = Math.floor (Leftsecond/(60 * 60 * 24)); - varhour = Math.floor ((leftsecond-day1 * 24 * 60 * 60)/3600); - varminute = Math.floor ((leftsecond-day1 * * * 60-hour * 3600)/60); - varSecond = Math.floor (leftsecond-day1 * * * 60-hour * 3600-minute * 60); in Try { - varCC =document.getElementById (divname); to if(minute = = 0 && second = 0) { +cc.innerhtml = "0 minutes 0 seconds"; -document.getElementById (' msg '). InnerHTML = "message: <font color=red> SMS Verification Timeout, please re-get SMS Verification code! <span> "; theWindow.clearinterval (Intervalid);//Stop Timing * return; $ }Panax Notoginsengcc.innerhtml = minute + "min" + Second + "SEC"; -}Catch(e) {} the } + Else { Acc.innerhtml = "0 minutes 0 seconds"; thedocument.getElementById (' msg '). InnerHTML = "message: <font color=red> SMS Verification Timeout, please re-get SMS Verification code! <span> "; +Window.clearinterval (Intervalid);//Stop Timing - } $ } $ varIntervalid = Window.setinterval (function() {Showcountdown (' t '); }, interval); -</script>
How to display the countdown on the page with JS code