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

D

Dag Sunde

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...
 
R

Randy Webb

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.
 
D

Dag Sunde

Randy Webb said:
Dag Sunde said the following on 9/2/2005 7:09 AM:


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top