I use the following to provide the auto-refresh page with a visual timer. It does more than you need, but you can throw it away for something simpler.
Run it when the page loads with
auto_refresh();
Auxiliary functions below
/** * This function checks if the auto-refresh check box is checked and then refreshes the page. * * */ function auto_refresh() { // **************************************** // Countdown display // **************************************** $("#countdown").progressbar({ value: 100 }); check_refresh(120, 120); $("#autorefresh").click(function() { if ($(this).attr("checked") == "checked") { $("#countdown").progressbar("option", "disabled", false ); $("#countdown").progressbar("option", "value", 100); check_refresh(120, 120); } }); }
A...
function check_refresh(countdownValue, secondsRemaining) { var autorefresh = $("#autorefresh"); if ($(autorefresh).attr("checked") == "checked") { setTimeout(function() { var value = Math.round(secondsRemaining / countdownValue * 100);
source share