473,416 Members | 1,597 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,416 software developers and data experts.

alert pop-up box when closing the browser window

Dear ASP.NET Programmers,

I am developing an intranet application using ASP.NET. I want to add such a
functionality that the application displays a pop-up box to confirm when the
user tries to close the windows using X box. I want the pop-up to be
displayed when the user clicks on the X box of the browser window (namely,
when the user closes the browser window). It's not important whether the
data is changed or not.
onbeforeunload event hook works also when I am changing the page. I only
want to display when the user closes the application window, not when he/she
browses to another page in the application. How can I accomplish this?
Thanks in advance,

Burak
Nov 19 '05 #1
1 3010
There is no easy way to accomplish this. From the perspective of DHTML DOM
model, closing of the browser window and going to a different page are the
same event.

However, you could probably trick the system into doing this. Here's how:

1) Define a flag that would be set to true, if the user on any of page's
links
2) Add "onclick" event handler to all anchor elements that lead to another
pages. The event handler will set the flag to true.
3) Add "onunload" event handler to window element that would check for the
flag and only display the alert box if the flag is not true.

This solution has limitations. For instance, if the user simply types a new
URL in the address bar, the flag will remain set to false, thus producing
the alert box.

Hope this helps.

:DG<

"buran" <b@b.com> wrote in message
news:OT**************@TK2MSFTNGP10.phx.gbl...
Dear ASP.NET Programmers,

I am developing an intranet application using ASP.NET. I want to add such
a
functionality that the application displays a pop-up box to confirm when
the
user tries to close the windows using X box. I want the pop-up to be
displayed when the user clicks on the X box of the browser window (namely,
when the user closes the browser window). It's not important whether the
data is changed or not.
onbeforeunload event hook works also when I am changing the page. I only
want to display when the user closes the application window, not when
he/she
browses to another page in the application. How can I accomplish this?
Thanks in advance,

Burak

Nov 19 '05 #2

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

Similar topics

4
by: Roy Smith | last post by:
In the recent "transforming a list into a string" thread, we've been discussing the fact that list.pop() is O(1), but list.pop(0) is O(n). I decided to do a little timing experiment. To be sure,...
1
by: L-and-F | last post by:
www.lee-mcgeorge.co.uk I've been using custom Alert boxes for a long time in various guises. The way I've shown below is perhaps the easiest. There are more efficient and cleaner ways to do it,...
3
by: dalei | last post by:
Is there a way to have non-English letters and symbols, such as the Greek letters or copyright sign, to appear in the box of alert()? Or is the alert () also available to people with other writing...
4
by: sonu | last post by:
How can we use alert and confirm method in asp.net application. i am working with application where i want to use confirm box before going for any operation. and same for alert box Sonu
2
by: jrsjrs | last post by:
The "filetest.txt" contents is here .................. one/yes two/no three/maybe four/fun five/ok ................ The main program is here
22
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. Using...
4
by: joe | last post by:
Hi, I defined: <div id="abc"> </div> in my .html file, after an Ajax query my weberserver sends: <script language="JavaScript"> alert('Hello World!"); </script>
25
by: Nicholas Parsons | last post by:
Howdy Folks, I was just playing around in IDLE at the interactive prompt and typed in dir({}) for the fun of it. I was quite surprised to see a pop method defined there. I mean is that a...
4
by: j_depp_99 | last post by:
The program below fails on execution and I think the error is in my pop function but it all looks correct.Also could someone check my code as to why my print function is not working? I havent...
5
by: vjsv2007 | last post by:
Can you help to make one alert with all details? <script type="text/javascript"> <!-- function validate_form ( ) { valid = true;
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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,...
0
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...

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.