Recently in the mobile to get the verification code countdown problem, found a problem, that is, when the screen hibernation or the program switch to the background, the iOS system countdown will be paused, but in the use of this is definitely a bug. My choice is to get the current timestamp to solve this problem, the specific code analysis is as follows:
function Time_a () { var time = 10; $ ( ". Time" var t = setinterval (function () { if (time = = 0) {cleartimeout (t); else {time --; $ (. Time " 1000
When using time--to Countdown, there will be a countdown fault on the IOS11. So I chose to use timestamps, and then with the time limit in the background, to resolve the background runtime limit for iOS.
functionTime_b () {vartime=10; varBegintime=NewDate (). GetTime (); $(". Time-a"). Text (time); varT= SetInterval (function(){ varNewtime=NewDate (). GetTime (); varDtime= (Newtime-begintime)/1000; Dtime=parseint (dTime); time= 10-dtime > 0? 10-dtime:0; $(". Time-a"). Text (time); },1000) }
iOS system screen hibernation or background run Countdown pause issue