Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

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

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
WhiteEagle
Asked:
WhiteEagle
1 Solution
 
sybeCommented:
i don't think you can.
0
 
kraigCommented:
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
 
jsmckenzieCommented:
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!

 
mgfranzCommented:
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
 
GaryCommented:
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
 
jsmckenzieCommented:
A grade of C?  For the wrong person?  If it didn't answer your question, don't accept an answer.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now