Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > alert pop-up box when closing the browser window

Reply
Thread Tools

alert pop-up box when closing the browser window

 
 
buran
Guest
Posts: n/a
 
      12-29-2004
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


 
Reply With Quote
 
 
 
 
Dimitri Glazkov
Guest
Posts: n/a
 
      12-29-2004
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.

G<

"buran" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
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
on click in popup window throws alert : need to avoid alert of postdata Ganesh ASP .Net 0 06-29-2007 06:51 AM
Closing popup window when closing parent window? =?Utf-8?B?Vk1J?= ASP .Net 3 02-15-2007 08:29 AM
programatically closing window.alert() dialogbox cruster Javascript 0 03-22-2006 10:17 AM
Closing child window WITHOUT closing parent thomas Javascript 0 10-23-2003 04:10 PM
closing window and alert problem... point Javascript 0 07-12-2003 01:20 PM



Advertisments