By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,886 Members | 1,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,886 IT Pros & Developers. It's quick & easy.

Detecting if onUnload() was called because of a refresh...

P: n/a
Is there a way to detect if the reason an onUnload()
handler was called originated from the user explicitly
refreshed the page(s)?

Ie. pressed "Ctrl-R", "F5" or klicked the refresh button
in the toolbar or the context menu?

I'm aware that I can not stop a refresh, but the reason
I want to know is that I have a hidden frame in an intranet
application. This hidden frame is present at all times after
the user have sucessfully logged in (to our db).

So the only time this frame is closed is when the user
navigates away from the intranet app. At which point I want
to log him/her out.

I do thid With an AJAX call in the unload-event of the hidden
frame.

*BUT*... This leads to logging out if the user presses "F5",
or in other ways refresh the window, since a refresh reloads
both frames.

So I thought that if I could detect that this was a refresh in
progress, I can avoid logging him/her out.

PS!
I only need this to work in an IE-only scenario.

TIA...

--
Dag.

Work is the curse of the drinking classes
-- Oscar Wilde
Sep 2 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Dag Sunde said the following on 9/2/2005 7:09 AM:
Is there a way to detect if the reason an onUnload()
handler was called originated from the user explicitly
refreshed the page(s)?
No.
Ie. pressed "Ctrl-R", "F5" or klicked the refresh button
in the toolbar or the context menu?
No.
I'm aware that I can not stop a refresh, but the reason
I want to know is that I have a hidden frame in an intranet
application. This hidden frame is present at all times after
the user have sucessfully logged in (to our db).
Not possible to know how it was loaded, only that it was loaded.
So the only time this frame is closed is when the user
navigates away from the intranet app. At which point I want
to log him/her out.
Use a session variable on the server. Never rely on the client.
I do thid With an AJAX call in the unload-event of the hidden
frame.

*BUT*... This leads to logging out if the user presses "F5",
or in other ways refresh the window, since a refresh reloads
both frames.
IFrame gets unloaded, user gets logged out.
IFrame gets reloaded, user gets logged back in.

Have the IFrame check, onload, to see if the user is logged in. If not,
refer them back to the login page. It won't take many refresh/relogins
for them to stop using the Refresh.
So I thought that if I could detect that this was a refresh in
progress, I can avoid logging him/her out.
Can't distinguish.
PS!
I only need this to work in an IE-only scenario.


Doesn't matter.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Sep 2 '05 #2

P: n/a
"Randy Webb" <Hi************@aol.com> wrote in message
news:t5********************@comcast.com...
Dag Sunde said the following on 9/2/2005 7:09 AM:
Is there a way to detect if the reason an onUnload()
handler was called originated from the user explicitly
refreshed the page(s)?


No.
Ie. pressed "Ctrl-R", "F5" or klicked the refresh button
in the toolbar or the context menu?


No.

<snipped />

Now, that was encouraging... ;-)

Ok... I drop that path then, and consentrate on the serverside.

Thanks for saving me a dead-end journey.

--
Dag.

Sep 2 '05 #3

P: n/a
Dag Sunde said the following on 9/2/2005 6:54 PM:
"Randy Webb" <Hi************@aol.com> wrote in message
news:t5********************@comcast.com...
Dag Sunde said the following on 9/2/2005 7:09 AM:

Is there a way to detect if the reason an onUnload()
handler was called originated from the user explicitly
refreshed the page(s)?
No.

Ie. pressed "Ctrl-R", "F5" or klicked the refresh button
in the toolbar or the context menu?


No.


<snipped />

Now, that was encouraging... ;-)


Glad I could be of help :)
Ok... I drop that path then, and consentrate on the serverside.
That's the best place to handle it.
Thanks for saving me a dead-end journey.


Welcome.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Sep 2 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.