javascript browser refresh buton

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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();">
 
AFAIK no. You may want to explain what you are trying to do. It could raise
other suggestions than capturing the refresh button...
 
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.
 
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...
 
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
 
Back
Top