Browser close event (MSIE and FF): how to detect browser close ?

Browser close event (MSIE and FF): how to detect browser close ?

Post by pamelaflue » Wed, 24 Jan 2007 09:44:42

Hi Guys

this time I have a question which involves both Javascript and perhaps

Ok. I am working on a sort of reporting systems which works like this:

There is an IIS ASP.NET server. On the server there is a binary file
(call it "Source Report") which
stores all informations to create an HTML page (call it "Web Report").

There is a JAVASCRIPT file on the server (which is referred to inside
the Web Report) which
is responsible to send, via get, some commands (for instance a "drill
down") from the Web report to
an file .aspx (call it "Report Processor"), which sends the command to
the server which, in case, regenerates the Web Report by a direct write
to disk and redirect the user's browser to the new version..

To allow concurrency, everytime a user make a request of a report, I do
this: I create a new temporary folder
(the name of the folder id a basically reportID+Timestamp). In the
temporary folder I copy the Source Report and then everything the user
does on the report (regeneration, drill, change the report by sending
parameters, etc) happens within that folder.

This way the user can work on multiple different instances of the same
Source Report, and can have completely different views (Web Reports) of
the same Source report. For each report instance which is created I
store all relevant information (including an identificator and temp
folder name) in a session variable, so it can be retrieved any time.
Each Web Reports stores inside the instance identificator.

--> Now my question. When the user closes the browser and goes away I
would like to be able to do some cleanup programmatically. For
instance, I would like to remove the temporary folders created to deal
with report instances.

Could you advise for the best method to detect when the user closes the
browser and send this information to the server through my aspx file
(Report Processor) ? In other words, can you see a function I can place
in my JS file which would transmit (via GET) the event to the aspx and
therefore to the server?

Hope I have been clear with my poor English. Please just ask if not ...

Thank you


1. Detecting browser close (X) event in ASP.NET

2. how to detect Browser close event.


I have a web Application that must be licensed. When Customer buys 2
licensees for my application they can only have 2 copies open at a time.
What I am doing right now is, I am storing No. Of License in the SQL
Table, and on each connection i would reduce 1 license from the DB. My
problem is when user closes IE Browser, I want to capture this event and
return the license to the DB. How do I know when user closed the
browser? I have more than one page in my application so from any page if
they close browser I should capture that event. I also have Automatic
refresh on couple of pages where it redraws pages from the DB every 5
mins. I should not clear the license upon refresh. I would really
appreciate your help.


*** Sent via Developersdex ***
Don't just participate in USENET...get rewarded for it!

3. Event to detect when browser is closed

4. Browser window getting closed when i open a new browser window

5. Java start new Process (Browser) and notice when Browser Window is closed.

6. Internet Browser - error report followed by browser closing

7. IE browser closes if I open up another/new browser

8. Closing 2nd browser window and restart movie on browser main window

9. What is the best way to handle browser crash or browser close?

10. Closing browser window - IE vs. other browsers

11. How can I close a remote front panel by closing only the browser window?

12. closing the pop up, closing all the browser windows

13. other browser windows close when closing one

14. Problem with all browsers closing at once when I close one tab

15. How to close child browser while parent close?