473,775 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3036
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******** ******@TK2MSFTN GP10.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
2416
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, I did verify experimentally the expected result, but along the way, I came upon an interesting artifact that I'm at a loss to explain. I used the following to generate some timing numbers for pop() on various sized lists: import time
1
22821
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, but this is so easy, it works a treat. You can also put new <DIV> tags inside the alert to have "Accept" "Decline" "Cancel" buttons www.lee-mcgeorge.co.uk
3
2608
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 systems? I tried with such as &delta;. It didn't display. This question is also for the prompt (). Thanks.
4
10389
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
43344
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
2326
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 this line of code works great. It displays a little message box with the alert message in it. Me.btnGetArchivedTrips.Attributes.Add("onMouseOver", "alert('mouse over')")
4
4033
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
4202
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 misnomer or what? From the literature, pop is supposed to be an operation defined for a stack data structure. A stack is defined to be an "ordered" list data structure. Dictionaries in Python have no order but are sequences. Now, does anyone know...
4
2567
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 included the other parts of my program but will if someone needs it. Please help; I have had it. I have checked all C++ websites and cannot figure it out. <code> template<class Type> void Novice<Type>::Print()
5
6303
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
9622
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
9454
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,...
1
10048
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
9916
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...
0
8939
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
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.