471,049 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,049 software developers and data experts.

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

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
3 14608
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
"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
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.

Similar topics

2 posts views Thread by DonO | last post: by
1 post views Thread by hqdtech | last post: by
2 posts views Thread by Peter Oliphant | last post: by
2 posts views Thread by 440gtx | last post: by
5 posts views Thread by tshad | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.