473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

deactivation of reloading on refresh button

Hi,
I have a web page that contain one count down timer.i want timer to continue the counting even some one press refresh button in IE or Firefox.
cant anybody help me.
Sep 26 '07 #1
5 3140
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Don't try to prevent the reload/refresh functionality.

You could use a cookie to keep the countdown timer value which can be updated when the page is reloaded.
Sep 26 '07 #2
Welcome to TSDN!

Don't try to prevent the reload/refresh functionality.

You could use a cookie to keep the countdown timer value which can be updated when the page is reloaded.

I m attaching my code here can you tell me the method to avoid reload/refresh functionality.
************************************************** ********************
[HTML]<html>
<head>
<title>Countdown Timer</title>
<style type="text/css">
#txt{border:none;font-family:verdana;font-size:16pt;font-weight:bold;border-right-color:#FFFFFF}
</style>
<script language="javascript" type="text/javascript">
<!--


function cd() // this function must be called from the <body onload=""> event
{
mins = 1 * m("10"); // change minutes here
secs = 0 + s(":01"); // change seconds here (always add an additional second to your total)
redo();
}

function m(obj)
{
for(var i = 0; i < obj.length; i++)
{
if(obj.substring(i, i + 1) == ":")
break;
}

return(obj.substring(0, i));
}

function s(obj)
{
for(var i = 0; i < obj.length; i++)
{
if(obj.substring(i, i + 1) == ":")
break;
}

return(obj.substring(i + 1, obj.length));
}

function dis(mins,secs)
{
var disp;

if(mins <= 9)
{
disp = " 0";
}
else
{
disp = "";
}

disp += mins + ":";

if(secs <= 9)
{
disp += "0" + secs;
}
else
{
disp += secs;
}


return(disp);
}


function redo()
{
secs--;

if(secs == -1)
{
secs = 59;
mins--;
}

document.cd.disp.value = dis(mins,secs); // setup additional displays here.

if((mins == 0) && (secs == 0))
{
window.alert("Time is up. Press OK to continue."); // change timeout message as required
window.location = "yourpage.htm" // redirects to specified page once timer ends and ok button is pressed
}
else
{
cd = setTimeout("redo()",1000);
}
}
//-->
</script>


</head>
<body onload="cd()">
<form name="cd">
<input id="txt" readonly="true" type="text" value="10:00" border="0" name="disp"><!-- change value to countdown start number //-->
</form>
</body>
</html>[/HTML]
************************************************** *******************
Sep 27 '07 #3
acoder
16,027 Expert Mod 8TB
Back, forward and reload/refresh buttons are standard browser buttons. Just leave them be.

Why do you want to prevent the reload? Is it because the timer will restart rather than carry on?
Sep 27 '07 #4
Back, forward and reload/refresh buttons are standard browser buttons. Just leave them be.

Why do you want to prevent the reload? Is it because the timer will restart rather than carry on?
yea the was that only.. i dont want timer to be reseted after refresh.can you help me?
Sep 28 '07 #5
acoder
16,027 Expert Mod 8TB
yea the was that only.. i dont want timer to be reseted after refresh.can you help me?
In that case, use a cookie to store the timer when started. Then when the page is refreshed, check if cookie exists. If it does, make a calculation based on that and the time that has elapsed and set the timer accordingly. If no cookie exists, start the timer and set a cookie. Read about getting, setting and removing cookies here.
Sep 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Greg Bryant | last post by:
Wondering why my setcookies didn't have any impact, I noticed the line in the manual that said the page needs to be reloaded before they take effect (which does make a certain kind of sense). So,...
3
by: Sam | last post by:
I am constructing a company intranet. On the intranet I made an overview-page which displays the availability of equipment. The information comes out of a database, and is retrieved by php-script....
6
by: iwearwatches | last post by:
Group, What a root canal. Here is what I have: I have a page that has several layers that I will either show/hide based on a graphic/tab that the user clicks. (works perfectly)
4
by: Joshua Weir | last post by:
Hi, I have 2 questions: 1. IF i create an object on the Page_Load event function of a specific aspx page. Like so: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As...
0
by: steve1rm | last post by:
Hello, I have a main form with a datagrid. When I add I click a add button and another form (customer form) will open. I enter in the new data and click add customer button. The customer is...
0
by: K B | last post by:
Hi, I could be approaching this all wrong...so please let me know what you think. I have a 2 page frame (WIleft.aspx and WIright.aspx) in asp.net 2.0. I create an html page by transforming xml...
1
nmm32
by: nmm32 | last post by:
I have this simple HTML page: <html> <head> <title></title> </head> <frameset cols="220,*" FRAMESPACING="0" BORDER="0" FRAMEBORDER="0"> <frame src="left.jsp" name="frame1"...
2
by: malcster2 | last post by:
hello, i am a beginner to ajax. i have created a mysql database, which i would like to access from a web page. i have created 3 files, a html to display the data, a php file to extract the data,...
2
by: sajankonni | last post by:
i want to refresh image buttons in asp.net,only without reloading the entire page.
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.