How to keep website's javascript timer enabled while iPhone is locked
When my website is opened in Safari开发者_开发百科 and the iPhone is put into sleep mode, any javascript timers (window.setTimeout) are not executed any more.
Is there a way that these timers get executed even if the screen is locked? It would be sufficient if this happens only if Safari is the active app and the website is the active "tab" in the moment of locking.
I read that apps can prevent "deep sleep" mode by regularly playing a soud. Does this also apply to websites?
Simply change your logic so it doesn't require constant ticks. If it's a countdown timer you could simple store the date every tick and compare the previous date to the current one in each tick - even if you got no ticks for a long time you exactly know which time passed since the last tick.
精彩评论