Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to distinguish between page-refresh and window-close ?

Reply
Thread Tools

How to distinguish between page-refresh and window-close ?

 
 
BennyVK@gmail.com
Guest
Posts: n/a
 
      08-28-2006
Hi,

I'm not sure if this question should go to the "JavaScript" section;
but I'm open to non-JavaScript (like VBScript) options too. So, I'm
posting this here.

I have the following problem:

For my application, I need to ask a confirmation when the user closes
the browser-window. If the answer is positive, I would like to log-off
the session and close the window. If the answer is negative, I would
like to stay back (no logging-off, no closing the window).

I can't do this in the window.unload event because the window is
already closed when the unload event is fired. I tried doing this in
the beforeUnload event. But the beforeUnload event gets called even
when I refresh the page and in that case, I don't want to ask this
question or logoff.

Can somebody help me in the above scenario? Please...

Thanks,
Benny Varghese

 
Reply With Quote
 
 
 
 
Dag Sunde
Guest
Posts: n/a
 
      08-28-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi,
>
> I'm not sure if this question should go to the "JavaScript" section;
> but I'm open to non-JavaScript (like VBScript) options too. So, I'm
> posting this here.
>
> I have the following problem:
>
> For my application, I need to ask a confirmation when the user closes
> the browser-window. If the answer is positive, I would like to log-off
> the session and close the window. If the answer is negative, I would
> like to stay back (no logging-off, no closing the window).
>
> I can't do this in the window.unload event because the window is
> already closed when the unload event is fired. I tried doing this in
> the beforeUnload event. But the beforeUnload event gets called even
> when I refresh the page and in that case, I don't want to ask this
> question or logoff.
>
> Can somebody help me in the above scenario? Please...
>


Yes, I can help you...

I had exactly the same question here some months ago, and with the
help of a lot of the regulars in this group we came to a conclusion:

Forget it! It can't be done in any reliable way!
I'm sorry.

Your best bet is a session timeout on the serverside.

--
Dag.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to distinguish between Events and States? Vinodh Kumar P C++ 1 12-12-2003 01:42 AM
distinguish between char* and char[x] mosfet C++ 6 11-27-2003 01:28 AM
How to distinguish between Olympus refurbished and new? Jerry Nash Digital Photography 4 11-19-2003 05:22 PM
How to distinguish between stdout and stderr Andre C Programming 7 07-21-2003 01:57 PM



Advertisments