javascript browser refresh buton

G

Guest

Hi,

Is there a javascript code to capture the browser's refresh button click
event ?
I know that I can handle that event with some c# code, but I was just
wondering if that can be done using javascript ?

Thanks.
Andrew.
 
L

Leon Mayne [MVP]

Andrew said:
Is there a javascript code to capture the browser's refresh button
click event ?
I know that I can handle that event with some c# code, but I was just
wondering if that can be done using javascript ?

Not sure about capturing the actual button click event, but you could attach
some code to fire on another event such as the page onunload event:
<body onunload="javascript:testCode();">
 
P

Patrice

AFAIK no. You may want to explain what you are trying to do. It could raise
other suggestions than capturing the refresh button...
 
G

Guest

Hi,

I have this textbox that I use to display a countdown timer, starting from
90:00, which is 90 minutes. The problem is that when the user clicks on the
REFRESH button of the browser, the timer refreshes itself and restarts from
90 minutes. How can I prevent that from happening and make the counter just
continue on ?

The counter value txtclock.value is called from the html body ie.
onload="start()".

Thanks.
Andrew.
 
P

Patrice

Keeping the time the counter started for the first time should work.
If you know the counter started at 11:10 when the page is refreshed at 11:20
you are able to start the counter for the remaining 80 minutes rather than
for the initial 90 minutes delay...
 
H

Hans Kesting

After serious thinking saurabh kumar manis wrote :
I have this textbox that I use to display a countdown timer, starting from
90:00, which is 90 minutes. The problem is that when the user clicks on the
REFRESH button of the browser, the timer refreshes itself and restarts from
90 minutes. How can I prevent that from happening and make the counter just
continue on ?


From
http://www.google.co.in/search?hl=e...rts+from+How+can+I+prevent+&btnG=Search&meta=

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com/g/

You have to store the required endtime somewhere. On a (re)start of the
page, check that store. If it is present, calculate the current time
from there. If it isn't there, create it with the 90 minute timeout.

For a client-side solution, you would use a cookie.
A server-side solution usually would use Session to store something
like this, but those sessions usually time out after 20 minutes of
inactivity!

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top