PDA

View Full Version : Detecting when the refresh button is pressed


jwendel
07-16-2002, 10:55 PM
Here is a tricky question for you. I want to detect when the refresh button is pressed. Without using onLoad(), onUnLoad(), or onBeforeUnLoad(). Can anyone help??


:thumbsup:

jeremy

Roy Sinclair
07-17-2002, 12:57 AM
It's not tricky at all. It's simply not possible, you're expecting too much from a language which was deliberately designed to not allow sites to be able to override the user, second guess the user or otherwise be an unstoppable pain for the user.

jwendel
07-17-2002, 04:11 AM
Is there any other language that this is possible with? (DHTML, JAVA) Can a java applet be useful in detecting the refresh button? :thumbsup:

Any suggestions?

mordred
07-17-2002, 10:28 AM
Writing your own ActiveX component perhaps?

...and hoping that users run IE on Windows platforms have there security settings opened wide...

jwendel
07-17-2002, 02:22 PM
Wouldn't an applet be more versatile on all platforms rather than just windows and IE. :rolleyes:

Yes/No.
jer

mordred
07-17-2002, 03:27 PM
And can an applet access the browser controls like the refresh button, hm? I thought that was your original question and you asked for suggestions?

Besides, how versatile is an applet in Windows XP that comes along without a JRE?

Roy Sinclair
07-17-2002, 03:35 PM
ActiveX might be able to do it but you'd have to get a signed control, get it marked as "safe for scripting" and get the users to use only IE and accept your control. OTOH Java is confined to it's sandbox and isn't going to be able to do what you want.

I can think of many good reasons to be able to detect the user's hitting the refresh button but I can also think of scenarios where it would be very bad for a page to intercept the button. Because of the latter, the former has also been made impossible.

Perhaps if you stated the problem behind your desire to watch the refresh button the good people here can suggest an alternative solution.

tamienne
07-17-2002, 05:48 PM
You can do it on the server side if the page doesn't allow for caching and in whatever language that you want provided your server is setup to understand it.

Another option is to write/read a cookie for this page and check to see # of times the page has been accessed.

jwendel
07-17-2002, 07:21 PM
Good point mordred, and thank you roy sinclair and tamienne. I will investigate your suggestions further, and maybe I can solve this almost impossible task.

:thumbsup: jeremy