473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4178
Be*****@gmail.c om 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
2244
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 getmimetype, but that does not seem te be reliab;e (dependent on the web server configuration). Can anyone help? The test should be something like: get url if isbinaryfile ($url) {
5
2720
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 first. Same problem, I seem not to be able to distinguish between a filesize of 0 bytes and FALSE. What am I doing wrong? --
1
2833
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 user's browser to be easily accessed, but doesn't appear to provide any method of distinguishing between data sent by POST and data sent by GET. Coming from PHP, where these two types of input are available in separate $_POST and $_GET arrays,...
6
2675
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; int *pas = &a; int *pah = new int; *pah = 10;
3
3176
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
1224
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 raises the click and the double click event. According to the documentation, that is the default behavior. I tried to change that by setting using Control.SetStyle with StandardClick and StandardDoubleClick(in every combination), but the
5
9755
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 | NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.Attributes |
7
1185
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 dependent on where it is called from. I would like to do one things if it is called from asp application, and other if it is called from WinForms app. Is there a way, I can distinguish where me library functions are called from?
1
1318
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 running by an outsider and when by an insider? How the browser knows? Thanks!!!
1
1036
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 facilities provided he must be a member. now when someone visits the home page and is not a member and tries to access one of the features, hes redirect to login page/register now page. but if the user has already signed in and then he tries to use a facility...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.