Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

58 of 110 people (53%) answered Yes
Recently 4 of 10 people (40%) answered Yes


Detect Reload so I can have a disabled button after initial click.

Apr 4th, 2008 20:38
ha mo, Iván Rivera, Amit Kulkarni,

Reload is not detectable nor trappable; there is no onReload event
handler. You could try some scheme using onUnload and URL search section
mangling, but onUnload is not guaranteed to work in some browsers for
timing reasons (the handler is out of scope when the page has finished
In your case I recommend that you use a cookie. Determine the expiration
period you need (the minimum one is the current session duration, which
is most useful for these cases). At the beginning of your page probe for
the existence of that cookie, and disable your button accordingly.
Remember that form elements have no disabled state in NS4.x, so use the
onFocus="blur()" technique for these browsers. If your button was
generated by a document.write(), you could even choose not to display it.
Hope this helps.