Tuesday, 15 January 2013

javascript - Reload web page when mobile device wakes from sleep -


I have created a countdown clock that works with JavaScript / HTML / PHP / My SQL.

As soon as you click on "Start Countdown", the time of the era is stored in the database and countdown starts.

When you reload the page, it goes to the database, the time of the era begins to count down, compared to that time the page was reloaded with that time and the rest of the time Calculates. Then starts in JS and continues the countdown without starting from the beginning. For example:

I set the countdown time to 100 seconds.

I click: Countdown starts

100, 99, 98, 97, 96 ...

I reload the page (say That takes 2 seconds to load it)

It continues where it should be: 94, 93, 92, 91 ... 0

Works perfectly on the browser (yes, even Internet Explorer), but I have a problem with mobile devices: When a mobile device sleeps, the countdown is off (I think Land that close the browser on the PC), and when I gave it awakens me, then leave it where I continue to count from where I left off, so the device then total seconds.

My question is: is there an event in javascript / jquery as soon as the mobile device is up, as soon as the fire is gone?

By checking online I found this:

This is a good solution, but it will contact the server every x seconds (in this case 5 seconds) when the user is on the page . This will cause lots of traffic to the page and I want to stop it. [Please correct me if i am wrong].

Any solution will be greatly appreciated!

Set the time remaining Do not set the time and calculate the remaining time at each interval between javascript and javascript The problem is resolved.


No comments:

Post a Comment