?
Solved

How can I detect that a user has clicked the window close button ?

Posted on 2003-03-03
6
Medium Priority
?
301 Views
Last Modified: 2008-01-16
I need to identify whether a page is being unloaded because the X button in the top right hand corner has been clicked rather than the page is being unloaded  because of some other postback event.
How can I do it?
0
Comment
Question by:WhiteEagle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 8056920
i don't think you can.
0
 
LVL 2

Expert Comment

by:kraig
ID: 8057031
The only way I can think of is to set some session variable whenever they click a link that takes them out of the page.  On unload of the page, check the value of the variable--if they used one of your controls the value could be true...if they used a global function (like back, forward or the 'X') the value could be false.
0
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 8057820
no way to do this with server-side ASP.... The only way I can think of other than using the JavaScript unload event is the onBeforeUnload event, which is IE 5+ only.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Accepted Solution

by:
mgfranz earned 225 total points
ID: 8058357
JavaScript onUnload(); (how do you think you get all those pop-up windows?)

onUnload = myJavaScriptCode
 
Event handler for Window
 
The onUnload event handler is used to run a function or JavaScript code whenever the user exits a document. The onUnload event handler is used within either the <BODY> or the <FRAMESET> tag, and uses the following properties of the Event object:
 
type - indicates the type of event
target - indicates the target object to which the event was sent.
 
The following example shows the onUnload event handler being used to execute the 'finishOff' function:
 
Code:
<BODY onUnload="finishOff()">
0
 
LVL 58

Expert Comment

by:Gary
ID: 9352537
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by mgfranz

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 9405640
A grade of C?  For the wrong person?  If it didn't answer your question, don't accept an answer.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question