countdown timer initializes on refreshing the page but it should not
-
Hello all, I have used the countdown timer in my asp.net project . It does working fine but the problem arises when I press f5 key or refresh in anyway..timer initialses again to maxmimum set time... So I need a solution for countdown timer that must not be affected on refreshing the page... Please help.......... thanks in advance Amit Jain
-
Hello all, I have used the countdown timer in my asp.net project . It does working fine but the problem arises when I press f5 key or refresh in anyway..timer initialses again to maxmimum set time... So I need a solution for countdown timer that must not be affected on refreshing the page... Please help.......... thanks in advance Amit Jain
Well, one answer is 'use frameset with timer in a frame that doesn't get refreshed'.
-
Well, one answer is 'use frameset with timer in a frame that doesn't get refreshed'.
Thanks for your reply bro.. But it doesn't work When I refresh the whole page ...frameset automatically refreshes and time again intialises to the given time (say 10 min) and starts counting down.. Any alternative to this ??
-
Thanks for your reply bro.. But it doesn't work When I refresh the whole page ...frameset automatically refreshes and time again intialises to the given time (say 10 min) and starts counting down.. Any alternative to this ??
blockquote class="FQ">
vinci007 wrote:
Any alternative to this ?? Yes, store the start time in a cookie. here is a very simple example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Timer Page</title>
</head>
<body>
here is a timer that will keep count<br /> even if page is refreshed<br />press button to reset<br />
<div id="timerDisplay"></div>
<div><input type="button" onclick="myTimer.reSet()" /></div>
</body>
<script type="text/jscript">
var myTimer = (function () {
var readCookie = function () {
var ca = document.cookie.split(';');
for (var i = ca.length; i--; ) {
var c = ca[i].split('name=');
if (c.length == 2) return c[1];
};
return 0;
};
if (!readCookie()) {
document.cookie = "name=" + (new Date().getTime()) + "; path=/";
};
var stuff = {};
stuff.howLong = function () {
return new Date().getTime() - readCookie()
};
stuff.reSet = function () {
document.cookie = "name=" + (new Date().getTime()) + "; path=/";
};
return stuff;
})();setInterval("document.getElementById('timerDisplay').innerHTML = myTimer.howLong();", 500); </script>
</html>
modified on Wednesday, August 25, 2010 9:45 PM