473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

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

Aug 28 '06 #1
1 4164
Be*****@gmail.com 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.

Aug 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: André Rosendaal | last post by:
Hi, I need a test so I can determine whether a url points to a text file or to a binary file. Actually, I need to distinguish between streaming files and metafiles (e.g. asx files). I tried...
5
by: John Bokma | last post by:
I want to use file_get_contents, which according to the documentation returns FALSE if it fails. However, it also fails if I read a file of 0 bytes in size. So I tried to use filesize to check...
1
by: Simon Willison | last post by:
Hi all, I've been experimenting with Python CGIs, and more recently mod_python. The FieldStorage class used by Python's cgi module and mod_python's utility library allows form data sent by a...
6
by: Sayan | last post by:
How do I distinguish between a heap pointer and a stack pointer? I want the following to work: template<class T> bool isHeapPtr(T* p1,T* p2);//the function I want to write //... int a = 5;...
3
by: buck | last post by:
reports/ can we alternate formatting such as "no shading" and then "shading" for multiple records such as a phone directory in Access2000 reports
0
by: Andreas Müller | last post by:
Hi All, I have a control derived from UserControl. Now I would like to distinguish between a click and a double click event on my control. The problem is, that on a doubleclick, the control...
5
by: Jon Maz | last post by:
Hi there, I am experimenting with the FileSystemWatcher object. I have set the NotifyFilter as follows: myFileSystemWatcher.NotifyFilter = NotifyFilters.Security | NotifyFilters.CreationTime...
7
by: Nikolay Petrov | last post by:
I have compiled some shared function in a lybrary, which I use in various application from asp pages, web services to winforms and windows services. some of the functionality in my libarary is...
1
by: niros | last post by:
Hi, I've noticed that IE have different security approach when loading a page from an inner intranet or when loading a page from the web. Is there a way in Javascript to know when your page is...
1
by: ankmahajan | last post by:
hi, im making my site as a platform where everyone can see whats on the site(even if hes not a member) except few facilities thta are only given to logged in users. And in order to use the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.